...

View Full Version : PHP form not sending email in correct format



lmorales
05-29-2012, 04:12 PM
I have a form on my page that sends an email to whoever, it sends the email so far, but it doesnt include any of the variables in it.

My test site is up at www.trendstudiosorlando.com/test3/index.htm

As of now, my php page is coded as follows: ( I have blocked out the email, but obviously it can be seen if you check, lol. Is my code wrong?

<?php
$errors = '';
$myemail = '********';//<-----Put Your email address here.
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];


{
$to = $myemail;
$email_subject = "You have an appointment request!: $name";
$email_body = "You have received an appointment request. ".
" Here are the details:\n Name: $name \n Email: $email \n Phone Number: $phone \n Details \n $comments";

$headers = "From: $myemail\n";
$headers .= "Reply-To: $email";

mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: contact-form-thank-you.html');
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Thank you</title>
</head>

<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>


</body>
</html>

SB65
05-29-2012, 04:55 PM
The contact form is missing name attributes for the input fields. In the absence of these there will be no POST data.

lmorales
05-29-2012, 07:21 PM
GOT IT! Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum