Thank you for the quick response.
I have pasted the suggested code into a contact.php page and uploaded. However, when testing the new form and leaving out info. in the required fields(first name, last name, phone, email) , the email is still processed and sent to my "sendmail.php" page without reloading the same page. Is there something that I'm missing here? Again, here is my new code. Thank you.
AAFDesign
contact.php
<?php
if(!isset($_POST['submit'])){
?>
<table width="350" border="0" align="center">
<tr>
<td width="525"><form action="sendmail.php" method="post">
<div align="left">
<table width="415" border="0">
<tr>
<td width="53%" align="right" valign="top"> <table width="100%" border="0">
<tr>
<td width="47%" align="right" valign="top"><p align="right"><span class="SmallText">
</span> </p>
<font color="#EEA644"></font><span class="SmallText">First
Name
<input name="firstname" type="text" size="15">
<br>
</span><font color="#EEA644"></font><span class="SmallText">Last
Name
<input name="lastname" type="text" size="15">
<br>
Company
<input name="company" type="text" size="15">
<br>
</span><font color="#EEA644"></font><span class="SmallText">Phone
<input name="phone" type="text" size="15">
<br>
Alt. Phone
<input name="altphone" type="text" size="15">
<br>
Fax
<input name="fax" type="text" size="15">
<br>
</span><font color="#EEA644"></font><span class="SmallText">Email</span>
<input name="email" type="text" size="15"> <br></td>
<td width="55%" align="right" valign="top"><p align="right"></p>
<span class="SmallText"> Address
<input name="address" type="text" size="20">
<br>
Address 2
<input name="address2" type="text" size="20">
<br>
City
<input name="city" type="text" size="20">
<br>
State
<input name="state" type="text" size="20">
<br>
Zip
<input name="zip" type="text" size="20">
<br>
Reffered By
<input name="referred" type="text" size="20">
<br>
Comments</span> <textarea name="comments" cols="15" rows="2"></textarea>
<br> <br> <input type="submit" name="Submit" value="Submit"> </p>
<p align="right"></p></td>
</tr>
</table></td>
</tr>
</table>
<p align="right"> </p>
</div>
</form></td>
</tr>
</table>
<?php
}
if(isset($POST['submit'])){
$firstname = $POST['firstname'];
$lastname = $POST['lastname'];
$company = $POST['company'];
$phone = $POST['phone'];
$altphone = $POST['altphone'];
$fax = $POST['fax'];
$email = $POST['email'];
$address = $POST['address'];
$address2 = $POST['address2'];
$city = $POST['city'];
$state = $POST['state'];
$zip = $POST['zip'];
$referred = $POST['referred'];
$comments = $_POST['comments'];
$err = array();
if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$", $email1) == FALSE){
$err[] = "Invalid email format given.";
}
if(eregi("^[A-Za-z]$", $firstname)){
$err[] = "Please enter your first name.";
}
if(eregi("^[A-Za-z]$", $lastname)){
$err[] = "Please enter your last name.";
}
if(empty($phone)){
$err[] = "Please enter a valid phone number.";
}
if(empty($referred)){
$err[] = "Please enter a refferal.";
}
if(count($err) == 0){
$msgbody = "Firstname: $firstname\nLastname: $lastname\nCompany: $company\nPhone: $phone\nAltphone: $altphone\nFax: $fax\nEmail: $email\nAddress: $address\nAddress2: $address\nCity: $city\nState: $state\nZip: $zip\nReferred: $referred\nComments: $comments";
@mail("email@aa5design.com", "1st Choice Dental: Email Us Form", stripslashes($msgbody), "From: ".$email);
echo "Thank you, <b>$firstname</b><b>$lastname</b> for your interest.<br>
We will reply to you at <i>$email</i>.<br></p>";
} else {
echo "ERRORS:<br>";
foreach($err as $error){
echo $error."<br>";
}
echo "Please go back and correct the errors.";
}
}
?>
sendmail.php
<?php # Script 2.2 - sendmail.php
$firstname = $POST['firstname'];
$lastname = $POST['lastname'];
$company = $POST['company'];
$phone = $POST['phone'];
$altphone = $POST['altphone'];
$fax = $POST['fax'];
$email = $POST['email'];
$address = $POST['address'];
$address2 = $POST['address2'];
$city = $POST['city'];
$state = $POST['state'];
$zip = $POST['zip'];
$referred = $POST['referred'];
$comments = $POST['comments'];
$msgbody = "Firstname: $firstname\nLastname: $lastname\nCompany: $company\nPhone: $phone\nAltphone: $altphone\nFax: $fax\nEmail: $email\nAddress: $address\nAddress2: $address\nCity: $city\nState: $state\nZip: $zip\nReferred: $referred\nComments: $comments";
@mail("email@aa5design.com", "1st Choice Dental: Email Us Form", stripslashes($msgbody), "From: $email");
echo "Thank you, <b>$firstname</b><b>$lastname</b> for your interest.<br>
We will reply to you at <i>$email</i>.<br></p>";
?>