<?php
/*
 *此时设置两个参数 1 为满意     2 为不满意 
 */
include_once("date/conn.php");
$user=$_POST[username1];
$sa=$_POST[satisfed];
$q_id=$_POST[q_id];
$result1=$pdo->query("select satisfed from tb_question where q_ID=$q_id");
foreach ($result1 as $row)
{
if($row[satisfed]!=null)
{
echo "<script>alert('该调查已经做过。');history.back();</script>";
exit;
}
}$result2=$pdo->query("select * from tb_question username='$user' and q_ID=$q_id");
if($result2->rowCount()==0)
{
echo "<script>alert('用户名不正确,谢谢你的参与');history.back();</script>";
exit;
}$result=$pdo->exec("insert into tb_question (satisfed)values('$sa')");
if($result)
{
echo "<script>alert('评论成功');location.href='index.php';</script>";
}
?>