0
我刚刚开始使用PHP进行编码,并且遇到一些问题以使此代码有效。我试图从$_POST
更改为$HTTP_POST_VARS
,但我仍然无法获得价值,任何人都可以指出我做错了什么,以及如何修复此代码?
<?php
$email_address = "[email protected]";
// your e-mail address goes here
$email_subject = "Online Enquiry";
// the subject line for the e-mail goes here
$from_email_name = "[email protected]";
// the from address goes here
$redirect_to_page = "thankyou.html";
// enter the web address where the user should be sent after completing the form
//*********************************
// DO NOT EDIT BELOW THIS LINE!!!**
//*********************************
$mailTo = "$email_address";
$mailSubject = "$email_subject";
$mailBody = "The form values entered by the user are as follows: \n\n";
foreach($_POST as $key=>$value)
{
$mailBody .= "$key = $value\n";
}
$mailBody .= "\n\n";
$fromHeader = "From: $from_email_name\n";
if(mail($mailTo, $mailSubject, $mailBody, $fromHeader))
{
print ("<B><br></b>");
}
echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$redirect_to_page\">";
?>
我的HTML表单。
<form action="contact.php" method="post">
<input type="text" class="textbox" value=" Your Name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Your Name';}">
<input type="text" class="textbox" value="Your E-Mail" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Your E-Mail';}">
<div class="clear"> </div>
<div>
<textarea value="Message:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Your Message ';}">Your Message</textarea>
</div>
<div class="submit">
<input type="submit" value="SEND " />
</div>
</form>
”并在这个PHP的东西新im“运行时,你在时间的儿子 –
表单提交后尝试打印'$ _POST);'。 –
你没有在$ _POST中使用任何东西。你只是测试是$ _POST不是空的。 '$ key'和'$ value'也是未定义的。你需要一个'foreach($ _ POST作为$ key => $ value)',很可能。 –