我可以帮助我关于php邮件程序..我使用的代码在某些情况下不起作用,我不知道为什么...当用户使用表单两次,php邮件程序不工作....这是我的代码:
<?php
$errors = '';
$myemail = 'juan91delacruz@gmail.com';//<-----Put Your email address `enter code here`here.
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['address']) ||
empty($_POST['contact']) ||
empty($_POST['pick_up_date']) ||
empty($_POST['time']) ||
empty($_POST['return_date']) ||
empty($_POST['time2']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$address = $_POST['address'];
$contact = $_POST['contact'];
$choose_car = $_POST['choose_car'];
$pick_up_date = $_POST['pick_up_date'];
$time = $_POST['time'];
$am_pm = $_POST['am_pm'];
$return_date = $_POST['return_date'];
$time2 = $_POST['time2'];
$am_pm2 = $_POST['am_pm2'];
$message = $_POST['message'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Reservation from: $name";
$email_body = "New reservation received. ".
" Here are the details:\n \n NAME: $name \n
EMAIL ADD: $email_address \n
ADDRESS: $address \n
CONTACT NUMBER: $contact \n
CHOOSEN CAR: $choose_car \n
PICK UP DATE: $pick_up_date $time $am_pm \n
RETURN DATE: $return_date $time2 $am_pm2 \n
MESSAGE: $message";
$headers = "From: $email_address\n";
//$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: thank-you.php');
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Contact form handler</title>
</head>
<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>
</body>
</html>
我希望有人能帮助我...... 非常感谢!