Hi:
I have created a simple contact form (see Form below), and a send_mail.php (see Send below) processor that verifies (not validates) the user has entered info all fields. Send then provides the user information and redirects them back to the contactus page. The problem I have is with the else statement; it does not echo anything back and only provides the end of the HTML page (</div></body></html>) to the user (resulting in a blank screen). The user is also not redirected back to the contact us page.
I have already tried various changes and found nothing works.
Any quidance would be appreciated.
Best Regards,
dennishall
Form:
<div>
<div>
<span style="font-family: Arial">
<span style="font-size: 14px">
<strong>
<span style="color: #003366">
CONTACT US
</span>
</strong>
</span>
</span>
</div>
<div>
 
</div>
<div>
<span style="font-size: 12px">
<span style="font-family: Arial">
To contact us, please fill out and submit the form below. We will respond to your inquiry as soon as possible.
</span>
</span>
</div>
<div>
<div>
 
</div>
<table width="100%">
<tbody>
<tr>
<td valign="top" width="50%" align="left">
<div>
<strong>
<span style="color: #003366">
<span style="font-size: 14px">
<span style="font-family: Arial">
Location
</span>
</span>
</span>
</strong>
</div>
<p>
<span style="font-size: 14px">
<span style="font-family: Arial">
Company name<br />
Address line 1<br />
Address line 2<br />
City, State/Province<br />
ZIP/Postal Code<br /><br />
Phone: (###) ###-####<br />
Fax: #-###-###-####
</span>
</span>
</p>
</td>
<td align="left" style="font-size: 14px">
<form method="post" action="send_mail.php" name="contact">
<div style="text-align: center; color: #003366">
<span style="font-size: 14px">
<span style="font-family: Arial">
<strong>
All fields must be completed to send us a message.
</strong>
</span>
</span>
</div>
<div style="text-align: left">
Name:<br />
<input maxlength="40" size="40" style="background-color: #efefef" name="name" type="text" />
</div>
<div>
E-Mail:<br />
<input maxlength="40" size="40" style="background-color: #efefef" name="email" type="text" />
</div>
<div>
Tel:<br />
<input maxlength="40" size="40" style="background-color: #efefef" name="phone" type="text" />
</div>
<div>
Subject:<br />
<input maxlength="40" size="40" style="background-color: #efefef" name="subject" type="text" />
</div>
<div>
Message:<br />
</div>
<div>
<textarea rows="12" cols="50" style="background-color: #efefef" name="message"></textarea>
</div>
<div style="text-align: center">
<input type="submit" name="submit" value="Send" />
</div>
</form>
</td>
</tr>
</tbody>
</table>
</div>
</div>
Send:
<?
error_reporting(E_ALL);
ini_set('display_errors', '1');
$contact_name = $_POST['name'];
$contact_email = $_POST['email'];
$phone = $_POST['phone'];
$contact_subject = $_POST['subject'];
$contact_message = $_POST['message'];
if( $contact_name && $contact_email && $phone && $contact_subject && $contact_message == true )
{
$sender = $contact_email;
$receiver = "name@domain.type";
$email_body = "Name: $contact_name \nEmail: $contact_email \nPhone: $phone \nSubject: $contact_subject \nMessage: $contact_message \n\nEmail forwarded from – name@domain.type";
$extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();
$subject = $_POST['subject'];
if( mail( $receiver, "Company name Contact Form - $subject", $email_body, $extra ) )
{
?>
<html>
<head>
<title>Contact Us Results</title>
<meta http-equiv="refresh" content="10;URL=http://www.domain.type/contactus.php">
<style type="text/css">
body {background-color: #efefef;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #123456;
text-decoration: none;
padding-top: 200px;
margin-left:auto;
margin-right:auto;
width: 800px;
}
</style>
</head>
<body>
<div align="center">
<? echo "Nous vous remercions de nous contactant à Nom du compangie.<br/>";
echo "S'il vous plaît patienter, nous vous revenez à la page CONTACTEZ-NOUS.<br/><br/>";
echo "Thank you for contacting us at Company name.<br/>";
echo "Please wait, we are returning you to the CONTACT US page.";
}
else // else routine only presents a blank screen and does not return the user in 10 seconds
// when source is viewed, only the last three lines are present </div></body></html>
{
echo "S'il vous plaît remplir tous les champs obligatoires.<br/><br/>";
echo "Please complete all the required fields.";
}
}
?>
</div>
</body>
</html>