我这里有这个简单的表单代码
<?php
$EmailFrom = "form@form.com";
$EmailTo = "s@outlook.com";
$Subject = "Form";
$Name = Trim(stripslashes($_POST['Name']));
$Budget = Trim(stripslashes($_POST['Budget']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Budget: ";
$Body .= $Budget;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
我想知道如何使顶部的起始地址与提交的地址相同。
答案 0 :(得分:0)
如果我理解正确,你可以完全取消这个变量:
$EmailFrom = "form@form.com";
这个修订后的mail()
函数应该按照您的要求执行:
// send email
$success = mail($EmailTo, $Subject, $Body, "From: " . $Email . "\r\n");
注意我已使用您已声明的以下变量:
$Email = Trim(stripslashes($_POST['Email']));