Hey guys,
The curious thing about this situation is that I am using virtually the same code (html, css, and php) on a contact form for another site and it works perfectly.
For some reason, I can't seem to get it to work on this site:
http://www.namastenutrition.net/form.htm
The form loads fine and it is accessing the php file, but everytime I fill it out and click submit, it loads the error2.html page and does not email me the information.
Any help would be most appreciated!!!
HTML:
<form id="myform" class="cssform" method="POST" action="php/contact.php">
<fieldset>
<legend>To contact me, simply fill out this form!</legend>
<p>
<label for="user">Name</label>
<input type="text" id="user" name="Name" value="" />
</p>
<p>
<label for="phonenumber">Phone Number:</label>
<input type="text" id="phonenumber" name="Phonenumber" value="" />
</p>
<p>
<label for="emailaddress">Email Address:</label>
<input type="text" id="emailaddress" name="Email" value="" />
</p>
<p>
<label for="regarding">Regarding:</label>
<input type="text" id="regarding" name="Regarding" value="" />
</p>
<p>
<label for="comments">Questions or Comments:</label>
<textarea id="comments" name="Comments" rows="5" cols="25"></textarea>
</p>
<div style="margin-left: 150px;">
<input type="submit" name="submit" value="Submit" class="submit"> <input type="reset" name="clear" value="Clear" class="clear">
</div>
</fieldset>
</form>
PHP:
<?php
// get posted data into local variables
$Email = Trim(stripslashes($_POST['Email']));
$EmailTo = "bentsime@gmail.com";
$Subject = "User Contact - Contact Page";
$Name = Trim(stripslashes($_POST['Name']));
$Phonenumber = Trim(stripslashes($_POST['Phonenumber']));
$Regarding = Trim(stripslashes($_POST['Regarding']));
$Comments = Trim(stripslashes($_POST['Comments']));
// validation
$validationOK=true;
if (Trim($Email)=="") $validationOK=false;
if (Trim($Name)=="") $validationOK=false;
if (Trim($Comments)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=../error2.html\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Phonenumber: ";
$Body .= $Phonenumber;
$Body .= "\n";
$Body .= "Regarding: ";
$Body .= $Regarding;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $Comments;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$Email>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=../thanks2.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=../error2.html\">";
}
?>