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.
 
 
 
 
 
 

35 lines
1.1 KiB

<?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;
}