NoteOnMe博客平台搭建
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

3 years ago
  1. <?php
  2. require_once "pdo.php";
  3. session_start();
  4. if(isset($_POST['feedback'])&&isset($_POST['feedback_id'])&&isset($_POST['comment_id'])&&isset($_POST['article_id']))
  5. {
  6. if (strlen($_POST['feedback']) < 1 ) {
  7. $_SESSION['error'] = '输入不能为空';
  8. header( 'Location: view.php?article_id='.$_POST['article_id']) ;
  9. return;
  10. }
  11. $sql = "INSERT INTO commentsss (comment_id,article_id,name,user_id,content,feedback_id)
  12. VALUES (:comment_id,:article_id,:name,:user_id,:comment,:feedback_id)";
  13. $stmt = $pdo->prepare($sql);
  14. try{
  15. $stmt->execute(array(
  16. ':comment_id' => $_POST['comment_id'],
  17. ':article_id' => $_POST['article_id'],
  18. ':name' => $_SESSION['name'],
  19. ':user_id' => $_SESSION['user_id'],
  20. ':comment' => $_POST['feedback'],
  21. 'feedback_id'=>$_POST['feedback_id']
  22. ));
  23. }catch (Exception $e) {
  24. $_SESSION['error'] = '非法';
  25. header( 'Location:view.php?article_id='.$_POST['article_id'] ) ;
  26. return;
  27. }
  28. $_SESSION['success'] = 'Record Added';
  29. header( 'Location: view.php?article_id='.$_POST['article_id']) ;
  30. return;
  31. }