Advertisement
misterH

code blog

Oct 20th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <?php // inserer un commentaire et redirection vers commentaires.php
  2. try
  3. {
  4. $db = new PDO('mysql:host=localhost;dbname=billets','root','root',array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
  5. }
  6. catch(Exception $e)
  7. {
  8. die('Error : ' .$e->getMessage());
  9. }
  10. $talab = $db->prepare('INSERT INTO commentaires (id_billet, auteur, commentaire, date_commentaire) VALUES(? ,?, ?, NOW())');
  11. $talab->execute(array($_POST['billet'],$_POST['auteur'],$_POST['commentaire']));
  12.  
  13.  
  14. header('Location: commentaires.php?billet='.$_POST['billet']);
  15. $talab->closeCursor();
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement