我完全不明白为什么这里的 php 没有向 IF 语句发送一个简单的变量。我尝试在 IF 语句中回显 $to_who 变量,但它什么都没有。因此,INSERT 语句没有为第一列插入任何内容。$to_who 变量在 IF 语句之前有一个数字。
$to_who = $_GET['id'];
require('connect.php');
echo $to_who;
$to_who_search = "SELECT * FROM donorstable WHERE donor_id = '$to_who'";
$to_who_raw = mysql_query($to_who_search);
$name = mysql_result($to_who_raw , 0 , 'first_name') . ' ' . mysql_result($to_who_raw , 0 , 'last_name') ;
$email = mysql_result($to_who_raw , 0 , 'email');
if(isset($_POST['submit1'])){
require('connect.php');
//gets from data
$getsubject = $_POST['subject'];
$getmessage = $_POST['message'];
//Gets user's email from table
$getformsql = "SELECT * FROM donorstable WHERE donor_id = '$userid'";
$getfrom = mysql_query($getformsql);
//builds email
$to = $email;
$subject = $getsubject;
$message = $getmessage;
$from = mysql_result($getfrom , 0 , 'email');
$headers = "From:" . $from;
//mail($to,$subject,$message,$headers);
echo "Mail Sent.";
$inserstatement = "INSERT INTO messages VALUES ('$to_who' , '$from' ,'$subject', '$message' , '0' , '')";
mysql_query($inserstatement);
}
谢谢