<?php
$adminemail = "[email protected]";
$subject = "YourDomain.com Enquiry";
if (isset($_POST["contact"]) && $_POST["contact"] == "1") {
$message = $_POST['message'];
$name = $_POST['name'];
$email = $_POST['email'];
$error1 = "<p><b>You Forgot To Enter Your Name</b></p>";
$error2 = "<p><b>You Forgot To Enter Your Email Address</b></p>";
$error3 = "<p><b>You Forgot To Enter A Message</b></p>";
$success = "<p><b>Your Message Been Submitted. Please Allow Up To 48 Hours For A Response</b></p>";
if ($name==""){$error=$error1;}
if ($email==""){$error=$error2;}
if ($message==""){$error=$error3;}
if ($name&&$email&&$message!=""){
if ($error==""){
$to = $adminemail;
$subject = $subject;
$header = "From: $name<$email>\n";
$header .="Content-type: text/html; charset=iso-8859-1\n";
$header .= "Reply-To: <$email>\n";
$header .= "X-Sender: <$email>\n";
$header .= "X-Mailer: PHP4\n";
$header .= "X-Priority: 3\n";
$header .= "Return-Path: <$email>\n";
$body = $message;
$error=$success;
mail($to, $subject , $body, $header);
}
}
}
?>
<form id="form1" method="post" action="">
<input type="hidden" name="contact" value="1"/>
<p>
<label>Your Name:
<input name="name" type="text" id="name" value="<?php echo $name; ?>" />
</label>
</p>
<p>
<label>Your Email Address:
<input name="email" type="text" id="email" value="<?php echo $email; ?>" />
</label>
</p>
<p>
<label>Your Message:
<br/>
<textarea name="message" id="message" cols="45" rows="5">
</textarea>
</label>
</p>
<?php echo $error; ?>
<p>
<label>
<input class="contactbutton" type="submit" name="submit" id="submit" value="Submit"/>
</label>
</p>
</form>
My Form:
PHP:<?php $adminemail = "[email protected]"; $subject = "YourDomain.com Enquiry"; if (isset($_POST["contact"]) && $_POST["contact"] == "1") { $message = $_POST['message']; $name = $_POST['name']; $email = $_POST['email']; $error1 = "<p><b>You Forgot To Enter Your Name</b></p>"; $error2 = "<p><b>You Forgot To Enter Your Email Address</b></p>"; $error3 = "<p><b>You Forgot To Enter A Message</b></p>"; $success = "<p><b>Your Message Been Submitted. Please Allow Up To 48 Hours For A Response</b></p>"; if ($name==""){$error=$error1;} if ($email==""){$error=$error2;} if ($message==""){$error=$error3;} if ($name&&$email&&$message!=""){ if ($error==""){ $to = $adminemail; $subject = $subject; $header = "From: $name<$email>\n"; $header .="Content-type: text/html; charset=iso-8859-1\n"; $header .= "Reply-To: <$email>\n"; $header .= "X-Sender: <$email>\n"; $header .= "X-Mailer: PHP4\n"; $header .= "X-Priority: 3\n"; $header .= "Return-Path: <$email>\n"; $body = $message; $error=$success; mail($to, $subject , $body, $header); } } } ?> <form id="form1" method="post" action=""> <input type="hidden" name="contact" value="1"/> <p> <label>Your Name: <input name="name" type="text" id="name" value="<?php echo $name; ?>" /> </label> </p> <p> <label>Your Email Address: <input name="email" type="text" id="email" value="<?php echo $email; ?>" /> </label> </p> <p> <label>Your Message: <br/> <textarea name="message" id="message" cols="45" rows="5"> </textarea> </label> </p> <?php echo $error; ?> <p> <label> <input class="contactbutton" type="submit" name="submit" id="submit" value="Submit"/> </label> </p> </form>
(Click Select All To See The HTML In The Code)