Hey everyone, I will be honest that I am still fairly new to PHP and what not, but I have been having some major issues trying to get my script to properly when trying to do a form submission...here is the code that I have done so far, but just not sure where i am going wrong....
<?php
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "someone@somesite.com";
$Subject = "Web-site Contact";
$FirstName = Trim(stripslashes($_POST['FirstName']));
$LastName = Trim(stripslashes($_POST['LastName']));
$Company = Trim(stripslashes($_POST['Company']));
$Phone = Trim(stripslashes($_POST['Phone']));
$Fax = Trim(stripslashes($_POST['Fax']));
$Comments = Trim(stripslashes($_POST['Comments']));
// validation
$validationOK=true;
if (Trim($FirstName)=="") $validationOK=false;
if (Trim($LastName)=="") $validationOK=false;
if (Trim($Company)=="") $validationOK=false;
if (Trim($EmailFrom)=="") $validationOK=false;
if (Trim($Phone)=="") $validationOK=false;
if (Trim($Fax)=="") $validationOK=false;
if (Trim($Comments)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=ctact_err.html\">";
exit;
}
//email body text
$Body = "";
$Body .= "FirstName: ";
$Body .= $FirstName;
$Body .= "\n";
$Body .= "LastName: ";
$Body .= $LastName;
$Body .= "\n";
$Body .= "Company: ";
$Body .= $Company;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Fax: ";
$Body .= $Fax;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $Comments;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body);
// redirect
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ctact.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=ctact_err.html\">";
}
?>
Each time the form is submitted it always sends the user to the error page that I have defined no matter what is going on with the actual form... here is the html I have just to make sure...
<form id="ctact" name="ctact" method="Post" action="frm_submit.php">
<div align="center">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="adv_ctact"><p>First Name*:</p></td>
<td><div align="left">
<input name="FirstName" type="text" id="FirstName" height="17px" size="20" maxlength="20" />
</div></td>
</tr>
<tr>
<td class="adv_ctact"><p>Last Name*:</p></td>
<td><div align="left">
<input name="LastName" type="text" id="LastName" height="17px" size="20" maxlength="20" />
</div></td>
</tr>
<tr>
<td class="adv_ctact"><p>Company*:</p></td>
<td><div align="left">
<input name="Company" type="text" id="Company" height="17px" size="20" maxlength="40" />
</div></td>
</tr>
<tr>
<td class="adv_ctact"><p>E-mail*:<br />
</p></td>
<td><div align="left">
<input name="EmailFrom" type="text" id="EmailFrom" height="17px" size="20" maxlength="60" />
</div></td>
</tr>
<tr>
<td class="adv_ctact"><p>Phone*:</p></td>
<td><div align="left">
<input name="Phone" type="text" id="Phone" height="17px" size="20" maxlength="20" />
</div></td>
</tr>
<tr>
<td class="adv_ctact"><p>Fax*:</p> </td>
<td><div align="left">
<input name="Fax" type="text" id="Fax" height="17px" size="20" maxlength="20" />
</div></td>
</tr>
<tr>
<td> </td>
<td><div align="left"></div></td>
</tr>
<tr>
<td class="adv_ctact"><p>Comments*:</p></td>
<td><div align="left">
<textarea name="Comments" cols="40" rows="10" id="Comments" height="17px"></textarea>
</div></td>
</tr>
<tr>
<td colspan="2" class="adv_ftr">All fields marked with an asterisk are required.</td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="submit"/> <input type="reset" name="Reset" value="reset" />
</div></td>
</tr>
</table>
</div></form>
Any help would be greatly appreciated.