NoteOnMe博客平台搭建
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

33 行
1006 B

<?php
require_once "pdo.php";
session_start();
if(isset($_POST['comment'])&&isset($_POST['id'])&&isset($_POST['article_id']))
{
if (strlen($_POST['comment']) < 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)
VALUES (:comment_id,:article_id,:name,:user_id,:comment)";
$stmt = $pdo->prepare($sql);
try{
$stmt->execute(array(
':comment_id' => $_POST['id'],
':article_id' => $_POST['article_id'],
':name' => $_SESSION['name'],
':user_id' => $_SESSION['user_id'],
':comment' => $_POST['comment']
));
}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;
}