我一直在使用电子邮件形式并遇到问题。
<?php
$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";
$fields = array();
$fields{"Name"} = "Name";
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$fields{"Message"} = "Message";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: [email protected]";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header("Location: http://www.YourDomain.com/thankyou.html");}
else
{print "We encountered an error sending your mail, please notify [email protected]"; }
}
}
?>
我试图运行它,但保持有错误与$name
变量。我做了一些调查,发现我也可以使用$$name
。我跑过去了,但没有奏效,所以我决定改变脚本的其他部分。我需要知道是否$name
或$$name
。我做了一些研究,发现$$name
是一个参考变量,而$name
只是一个变量。我需要知道每个人会得到什么结果,以及我应该使用哪一个。
你有什么错误? – showdev