NoteOnMe博客平台搭建
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

35 rader
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;
}