bonjour
j'ai testé comme ça , ça fonctionne
j'ai rajouté une une redirection plus quelques trucs ...
ok !
je pense que l'erreur vient des requetes
a++
Code PHP :
<?php
// Active tout les warning. Utile en phase de développement
// En phase de production, remplacer E_ALL par 0
error_reporting(0);
// Inclus le fichier contenant les fonctions personalisées
include_once 'S_DPHSOFT/mes_fonctions.php';
// Fonction de connexion à la base de données
//connexion_DB('dphsoft');
?>
<html>
<head>
</head>
<body>
<br />
<?php
function connexion_DB(){
mysql_connect('localhost','root','');
mysql_select_db('dan');
}
//Connexion à la bdd
connexion_DB();
//Recherche de tous les commentaires par la requete SELECT
$reqSQL="SELECT * FROM `comment` ORDER BY idcomment DESC";
$reponse=mysql_query($reqSQL);
//$reponse=requete_SQL($reqSQL);
while($donnees=mysql_fetch_array($reponse))
{
//Affichage des commentaires
?> Par <?php echo $donnees['nomComment'] ;?> Le <?php echo $donnees['dateComment']; ?> <br /> <hr />
<?php echo $donnees['lcomment']; ?> <br />
<hr />
<?php }
mysql_close;
?>
//Formulaire d'ajout de nouveau commentaires
<?php echo $link='http://' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];?>
<form name="comment" method="post" action="<?php echo 'http://' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI']; ?>">
<table border=0>
<tr><td>NOM*</td><td><input id="nom" type="text" name="nom" maxlength="25" /></td></tr>
<tr><td>ADRESSE MAIL*</td><td><input id="mail" type="text" name="mail" /></td></tr>
</table>
<label>Votre commentaire<br />
<textarea id="text8" class="ckeditor" name="texte" cols="40" rows="10" onkeyup="compteCarac('text8', 'nbCarac8');" ></textarea>
<span id="nbCarac8">0</span> caractère(s)
<br />
<input type="submit" name="valider" value="Envoyer" onclick="verification();"/>
<input type="reset" value="Vider" />
</form>
//Ajout de nouveau commentaire
<?php if (isset($_POST['valider']) && !empty($_POST['texte']) && $_POST['texte']!=null) {
echo 'ok';
//$date = getdate();
echo $date;
connexion_DB();
$_ENV['id_p']="toto";
echo $reqSQL="INSERT INTO `comment` (
`idcomment` ,
`lcomment` ,
`id_pageec` ,
`nomComment` ,
`adresseMail,` ,
`dateComment`
)
values (null, '".$_POST['texte']."', '".$_ENV['id_p']."', '".$_POST['nom']."', '".$_POST['mail']."', now())";
if($reponse=mysql_query($reqSQL)){
echo 'yo';
}else{
echo 'nyo';
}
//requete_SQL($reqSQL);
//deconnexion_DB();
$_POST['texte']=null;
mysql_close();
header('Location: '.$link);exit;
}else{
echo 'err';
}
?>
</body>
</html>
CREATE TABLE IF NOT EXISTS `comment` (
`idcomment` int(11) NOT NULL AUTO_INCREMENT,
`lcomment` varchar(50) NOT NULL,
`id_pageec` varchar(50) NOT NULL,
`nomComment` varchar(50) NOT NULL,
`adresseMail,` varchar(50) NOT NULL,
`dateComment` datetime NOT NULL,
PRIMARY KEY (`idcomment`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
--
-- Contenu de la table `comment`
--
INSERT INTO `comment` (`idcomment`, `lcomment`, `id_pageec`, `nomComment`, `adresseMail,`, `dateComment`) VALUES
(4, 'xvn', 'toto', 'xvn', 'xvn', '2011-05-03 11:06:02'),
(2, 'xvn', 'toto', 'xvn', 'xvn', '2011-05-03 11:04:11'),
(3, 'xvn', 'toto', 'xvn', 'xvn', '2011-05-03 11:04:16'),
(5, 'xvn', 'toto', 'xvn', 'xvn', '2011-05-03 11:06:30'),
(6, 'dfh', 'toto', 'dfh', 'dfh', '2011-05-03 11:06:51'),
(7, 'dfh', 'toto', 'dfh', 'dfh', '2011-05-03 11:06:55');

Bonne programmation !