提交表單後,php代碼將在底部打印錯誤消息,而不是發送電子郵件。我不知道在代碼的問題是PHP電子郵件表單不發送,打印錯誤
<?php
if (strtolower($_POST['code']) != 'opencom')
{
die('Error. Please type the word 'OPENCOM' in the appropriate field again');
}
if (isset($_POST['submit']))
{
$to = "[email protected]";
$subject = "2015 Rally Registration";
$VehicleType_field = $_POST['VehicleType'];
$PilotName_field = $_POST['PilotName'];
$PilotEmail_field = $_POST['PilotEmail'];
$PilotCell_field = $_POST['PilotCell'];
$CoPilotName_field = $_POST['CoPilotName'];
$CoPilotEmail_field = $_POST['CoPilotEmail'];
$CoPilotCell_field = $_POST['CoPilotCell'];
$VehicleInfo_field = $_POST['VehicleInfo'];
$VehiclePlates_field = $_POST['VehiclePlates'];
$POP_field = $_POST['POP'];
$body = "Vehicle Type: $VehicleType_field\n Pilot Name: $PilotName_field\n Pilot E-mail: $PilotEmail_field\n Pilot Cell: $PilotCell_field\n Co Pilot Name: $CoPilotName_field\n Co Pilot E-mail: $CoPilotEmail_field\n Co Pilot Cell: $CoPilotCell_field\n Vehicle Info: $VehicleInfo_field\n Vehicle Plates: $VehiclePlates_field\n Proof of Purchase: $POP_field\n";
$success = mail($to, $subject, $body);
}
if ($success)
{
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.lacesusa.org/rallythanks\"-->
<html>
<head>
<meta content="text/html;
charset = windows - 1252" http-equiv="content - type">
</head>
<body>";
}
else
{
echo "Sorry error please try again...";
} ?> </body > </html >
這是錯誤的打印:; }其他{回聲「對不起,請再試一次...」; } – A8F9F 2015-03-13 11:29:56
使用嘗試抓住並更新我的錯誤..我希望你使用它的主機..你沒有這樣做在本地.. 嘗試{$ to,$ subject,$ body}; } catch(Exception $ x){echo $ x-> getMessage();} – 2015-03-13 11:30:50
是否有語法錯誤?代碼中有太多未經轉義的引號。 – 2015-03-13 11:38:46