提交表单后,php代码会在底部打印错误消息而不是发送电子邮件。我不确定代码中的问题在哪里
<?php
if (strtolower($_POST['code']) != 'opencom')
{
die('Error. Please type the word 'OPENCOM' in the appropriate field again');
}
if (isset($_POST['submit']))
{
$to = "rally@lacesusa.org";
$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 >
答案 0 :(得分:0)
试试这个..
<?php
if (strtolower($_POST['code']) != 'opencom')
die('Error. Please type the word 'OPENCOM' in the appropriate field again');
if(isset($_POST['submit'])) {
$to = "rally@lacesusa.org";
$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";
if (@mail($to, $subject, $body)){
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>