我正在建立一个数据库验证系统。验证后,处理程序应该将数据发送到电子邮件地址,同时将数据更新到另一个数据库。从上一页接收id,name,board,query和rand的值。 现在,使用给定的代码,我无法更新名为' answers'在我的数据库中。此功能的代码行以粗体显示。
<?php
$servername = "localhost";
$username = "root";
$password = '';
$dbname = "bsp";
$conn1 = new mysqli($servername, $username, $password, $dbname);
$id="";
$value = "";
$name = "";
$board = "";
$query="";
$id = $_POST['id'];
$name = $_POST['name'];
$board = $_POST['board'];
$query = $_POST['query'];
$rand = $_POST['rand'];
$value=$_POST['option'];
$to="";
$subject="";
$msg="";
$headers="";
if($value=='delete')
{
$sql="DELETE FROM rti WHERE ID=$id";
if ($conn1->query($sql) === TRUE) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . $conn1->error;
}
}
else if($value=='validate')
{
**$sql="INSERT INTO answers (name, board, query, rand) VALUES (\"$name\", \"$board\", \"$query\", \"$rand\")";**
if($board=='BRCA')
{
$to = 'email@gmail.com';
$subject = 'RTI Query: Do not reply to this email.';
$msg = "Your code is " . $rand . ".";
$msg .= " Visit localhost/BSP/landing.php and post the code, and subsequently your answer.";
$headers = 'From: contact@yoursite.com';
mail($to, $subject, $msg, $headers);
}
else if($board=='BSW')
{
$to = 'email@rediffmail.com';
$subject = 'RTI Query: Do not reply to this email.';
$msg = $query;
$headers = 'From: contact@yoursite.com';
mail($to, $subject, $msg, $headers);
}
else if($board=='BSA')
{
$to = 'email@iitd.ac.in';
$subject = 'RTI Query: Do not reply to this email.';
$msg = $query;
$headers = 'From: contact@yoursite.com';
mail($to, $subject, $msg, $headers);
}
else if($board=='BSP')
{
$to = 'email@gmail.com';
$subject = 'RTI Query: Do not reply to this email.';
$msg = $query;
$headers = 'From: contact@yoursite.com';
mail($to, $subject, $msg, $headers);
}
else if($board=='BHM')
{
$to = 'email@gmail.com';
$subject = 'RTI Query: Do not reply to this email.';
$msg = $query;
$headers = 'From: contact@yoursite.com';
mail($to, $subject, $msg, $headers);
}
}
if(mail($to, $subject, $msg, $headers)==TRUE)
{
echo "The mail was sent successfully.";
}
$conn1->close();
?>