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)',很可能。 –