1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="Design.css">
</head>
<header>
</header>
<body>
<section class="commentaire">
<table>
<tr>
<td>Commentaires:</td>
</tr>
</table>
</body>
</html>
<?php
try {
$bdd= new PDO('mysql:host=localhost;dbname=essai;charset=utf8','root','');// connexion
}
catch(exception $e){
die('Erreur : '.$e->getMessage()); // renvoie un message derreur sil en existe
}
if (isset($_POST['nom']) && isset($_POST['prenom']) && isset($_POST['commentaire'])){ //condition
$nom = htmlspecialchars($_POST['nom']);
$prenom = htmlspecialchars($_POST['prenom']);
$commentaire = htmlspecialchars($_POST['commentaire']);
$requete = $bdd->prepare('INSERT INTO essai_commentaire(nom, prenom,commentaire) VALUES(?,?,?)');// insertion des donnees dans la base de donnes
$requete->execute(array($nom,$prenom,$commentaire)); // execution de la requete preparer
}
$requete = $bdd-> query('SELECT nom,prenom,commentaire FROM essai_commentaire');
while ($donnees = $requete->fetch()){
echo '<table><tr><td>'.'commentaire de '.$donnees['nom'].'</td>'.' '.'<td>'.$donnees['prenom'].'</td></tr>'.'<tr><td>'.$donnees['commentaire'].'</td></tr>';
}
{
echo '</table>';
}
$requete->closecursor();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="Design.css">
</head>
<body>
<section class="zoneR">
<form method="post" action="index.php">
<fieldset>
<legend>Inscrivez un commentaire : </legend>
<label>Nom</label><br><input type="text" name="nom" size="40"/><br>
<label>Prenom</label><br><input type="text" name="prenom" size="40"/><br>
<label>Commentaire: </label><br><textarea name="Commentaire" size="80"></textarea> <br>
<button type="submit">Envoyer</button><button type="reset" name="renitialiser">Renitialiser</button>
</fieldset>
</form>
</section>
</body>
<footer>
</footer>
</html> |