|
|
- <?php
- require_once "pdo.php";
- session_start();
-
- if(isset($_POST['feedback'])&&isset($_POST['feedback_id'])&&isset($_POST['comment_id'])&&isset($_POST['article_id']))
- {
- if (strlen($_POST['feedback']) < 1 ) {
- $_SESSION['error'] = '输入不能为空';
- header( 'Location: view.php?article_id='.$_POST['article_id']) ;
- return;
- }
-
- $sql = "INSERT INTO commentsss (comment_id,article_id,name,user_id,content,feedback_id)
- VALUES (:comment_id,:article_id,:name,:user_id,:comment,:feedback_id)";
- $stmt = $pdo->prepare($sql);
- try{
- $stmt->execute(array(
- ':comment_id' => $_POST['comment_id'],
- ':article_id' => $_POST['article_id'],
- ':name' => $_SESSION['name'],
- ':user_id' => $_SESSION['user_id'],
- ':comment' => $_POST['feedback'],
- 'feedback_id'=>$_POST['feedback_id']
-
- ));
- }catch (Exception $e) {
- $_SESSION['error'] = '非法';
- header( 'Location:view.php?article_id='.$_POST['article_id'] ) ;
- return;
- }
-
- $_SESSION['success'] = 'Record Added';
- header( 'Location: view.php?article_id='.$_POST['article_id']) ;
- return;
- }
|