我會承認,我不是最好的PHP,但我所做的通常對我來說足夠好,因爲客戶端只需要發送給他們的電子郵件的信息,並且這個安全問題足以讓垃圾郵件遠離他們的收件箱。但由於某種原因,此代碼將無法工作,我不明白爲什麼。這個具有不同變量的代碼在另一個網站上,並且已經過測試和工作。有人有建議嗎?PHP正在加載,但沒有發送電子郵件給我
<form action="submit_form.php" method="POST" >
<p>Name<br /><input type="text" name="name" required /></p>
<p>Email Address<br /><input type="text" name="email" required /></p>
<p>Phone Number<br /><input type="text" name="phone" required /></p>
<p>County<br /><input type="text" name="county" required /></p>
<p>Annual Income<br /><input type="text" name="income" required /></p>
<p>What is 4 + 1? (anti-spam)<br /><input type="text" name="answer" required /></p>
<input type="submit" value="Take The First Step" />
</form>
<?php # BOOST
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$county = $_POST['county'];
$income = $_POST['income'];
$correct_answer = '5';
$answer = $_POST['answer'];
if ($correct_answer != $answer) {
die("You're not a valid user of this site!");
}
else {
$to = "[email protected]";
$subject = "USDA LOANS";
$message = "USDA LOANS:\n
Name: $name
Email: $email
Phone: $phone
County: $county
Annual Income: $income";
$from = "USDA Loans";
mail($to,$subject,$message,$headers);
echo "Thank you for getting in contact with us. We will be in contact with you soon regarding your USDA Loan! <a href=http://www.usdaloansmo.com>Click Here</a> to go back to our website!";
}
?>
請注意,您錯過了開放的PHP標記。 '?php'應該是'<?php' – Ryan
我在這裏修正了它,但這只是從我的文檔複製時發生錯誤。謝謝 –
你需要自己做一些基本的調試嗎?檢查'mail()'的返回值是否爲布爾值false(失敗)。檢查你的郵件服務器的日誌,看看PHP是否正確地交出了電子郵件,以及之後發生了什麼。 –