So I need help with my contact form for my webpage. You can view the page at www.jacobdunklee.com
Here is the code for the www.jacobdunklee.com/Contact Me.html page I highlighted the actual part that is the contact form.
</div>
<div id="Body" style="position: relative; width: 800px; height: 664px; z-index: 3; margin-left: auto; margin-right: auto; left: 0px; top: 0px;">
<div id="Bleftcolumn" style="position: relative; width: 470px; height: 619px; z-index: 1; float: left; left: 0px; top: 0px;" class="style2">
<div id="ContactForm" class="style1" style="position: relative; width: 450px; z-index: 1; margin-left: 15px; height: 584px; top: 0px">
<form method= "post" action="mailer.php">
<input type="hidden" name="required" value="YourName, YourEmail, Subject, Message"/>
<p class="contactform"><span class="style4">Your Name:*</span><br />
<input name="YourName" type="text" /></p>
<p class="contactform"><span class="style4">Your Email:*</span><br />
<input name="YourEmail" type="text" /></p>
<p class="contactform"><span class="style4">Phone Number:</span><br />
<input name="PhoneNumber" type="text" /></p>
<p class="contactform"><span class="style4">Subject:*</span><br />
<input name="Subject" type="text" /></p>
<p class="contactform"><span class="style4">Message:*</span><br />
<textarea name="Message" style="width: 405px; height: 200px"></textarea></p>
<p class="style2"><input name="Reset1" type="reset" value="reset" />
<input name="Submit" type="submit" value="Send" /><input type="hidden" name="order" value="YourName,YourEmail,PhoneNumber,Subject,Message" /></p>
<p class="style4">Fields marked with an (*) are required.</p>
</form>
</div>
I then have a separate page for my mailer.php file which has the code of:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>
<body>
</body>
</html>
<?php
if(isset($_POST['submit'])) {
$myemail = "Jacob.Dunklee@JacobDunklee.com";
$YourName = $_POST['YourName'];
$YourEmail = $_POST['YourEmail'];
$PhoneNumber = $_POST['PhoneNumber'];
$Message = $_POST['Message'];
$headers = "From:Contact Form <$myemail>\r\n";
$headers .= "Reply-To: $name <$YourEmail>\r\n";
echo "www.JacobDunklee.com/FormCompletion";
mail($myemail, $YourName, $YourEmail, $PhoneNumber, $Message, $headers);
} else {
echo "www.JacobDunklee.com/Form Error.html";
}
?>
Please help because this is not working right. I want it to be redirected to those two pages once complete, but every time I hit submit on the page it just comes up with www.JacobDunklee.com/Form Error.html
I have no clue what I did wrong, it should work because it was copied directly from a working contact form the only difference is the host. The working one is through a paid site at ipage and this one is free through awardspace. But both support .php files and mailers..
Got this working with the following code:
contact form part
<div id="Body" style="position: relative; width: 800px; height: 664px; z-index: 3; margin-left: auto; margin-right: auto; left: 0px; top: 0px;">
<div id="Bleftcolumn" style="position: relative; width: 470px; height: 619px; z-index: 1; float: left; left: 0px; top: 0px;" class="style2">
<div id="ContactForm" class="style1" style="position: relative; width: 450px; z-index: 1; margin-left: 15px; height: 584px; top: 0px">
<form method= "post" action="mailer1.php">
<p class="contactform"><span class="style4">Your Name:*</span><br />
<input name="YourName" type="text" /></p>
<p class="contactform"><span class="style4">Your Email:*</span><br />
<input name="YourEmail" type="text" /></p>
<p class="contactform"><span class="style4">Phone Number:</span><br />
<input name="PhoneNumber" type="text" /></p>
<p class="contactform"><span class="style4">Subject:*</span><br />
<input name="Subject" type="text" /></p>
<p class="contactform"><span class="style4">Message:*</span><br />
<textarea name="Message" style="width: 405px; height: 200px"></textarea></p>
<p class="style2"><input name="Reset1" type="reset" value="reset" />
<input name="Submit" type="submit" value="Send" /></p>
<p class="style4">Fields marked with an (*) are required.</p>
</form>
and mailer.php part
<?php
$myemail = "contact@jacobdunklee.com";
$YourName = $_POST['YourName'];
$YourEmail = $_POST['YourEmail'];
$PhoneNumber = $_POST['PhoneNumber'];
$Subject = $_POST['Subject'];
$Message = $_POST['Message'];
$headers .= "Reply-To: $YourEmail\r\n";
// validation
$validationOK=true;
if (Trim($YourEmail)=="") $validationOK=false;
if (Trim($YourName)=="") $validationOK=false;
if (Trim($Subject)=="") $validationOK=false;
if (Trim($Message)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=FormError.html\">";
exit;
}
// prepare email body text
$PhoneNumberOK=true;
$Body = "";
$Body .= "Name: ";
$Body .= $YourName;
$Body .= "\n";
if (Trim($PhoneNumber)=="") $PhoneNumberOK=false;
if ($PhoneNumberOK) {
$Body .= "Phone: ";
$Body .= $PhoneNumber;
$Body .= "\n";
}
$Body .= "\n";
$Body .= "Message: ";
$Body .= "\n";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($myemail, $Subject, $Body, $headers);
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=FormCompletion.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=FormError.html\">";
}
?>
No comments:
Post a Comment