I need your help to check if my autoresponder will work in the following
script. I am testing my PHP scripts on free server, which dosen't allow me
to send email letters from my website.
Please tell me if every thing is ok, if not please correct my mistake. Thank
you for your help.
This is: "contact_form.p hp"
<?
// This is the beginning of the PHP code
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$error_msg = "";
$msg = "";
if(!$email){
$error_msg .= "Your email \n";
}
if($email){
if(!eregi("^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\._\-]+\.[a-zA-Z]{2,4}", $email)){
echo "\n<br>That is not a valid email address. Please <a
href=\"javascri pt:history.back ()\">return</a> to the previous page and try
again.\n<br>";
exit;
}
$msg .= "Email: \t $email \n";
}
if($comments){
$msg .= "Comments: \t $comments \n";
}
$sender_email=" ";
if(!isset($name )){
if($name == ""){
$sender_name="W eb Customer";
}
}else{
$sender_name=$n ame;
}
if(!isset($emai l)){
if($email == ""){
$sender_email=" Customer@websit e.com";
}
}else{
$sender_email=$ email;
}
if($error_msg != ""){
echo "You didn't fill in these required fields:<br>"
.nl2br($error_m sg) .'<br>Please <a
href="javascrip t:history.back( )">return</a> to the previous page and try
again.';
exit;
}
$mailheaders = "MIME-Version: 1.0\r\n";
$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$mailheaders .= "From: $sender_name <$sender_email> \r\n";
$mailheaders .= "Reply-To: $sender_email <$sender_email> \r\n";
mail("your@emai l.com","Contact Us"stripslashes ($msg), $mailheaders);
header("Locatio n: http://yahoo.com/"); /* Redirect browser */
$myname = "Your Name Here";
$mymail = "your@email.com ";
$subject = "Thank you for your mail!";
$body = "Hi. This is an auto response to let you know that I've successfully
received your
email sent through my email form @ mywebsite.com. Thanks! I'll get back to
you
shortly.";
$headers = "Content-Type: text/plain; charset=us-ascii From: $myname
<$mymail> Reply-To: <$mymail> Return-Path: <$mymail> X-Mailer: PHP";
if ($email != "") { mail($email,$su bject,$body,$he aders); }
//This is the end of the PHP code
?>
And this is a simple "contact form" for the script.
<!-- BEGIN THE COPYING HERE!!!!!!! --><!-- beginning of the form -->
<form METHOD=POST ACTION="contact _form.php">
<table width="300" border="0" cellspacing="0" cellpadding="0" >
<tr><td>Name: </td><td> <I NPUT TYPE="text" NAME="name"></td></tr>
<tr><td>E-mail:</td><td> <I NPUT TYPE="text" NAME="email"></td></tr>
<tr><td valign="top">Co mments:</td><td><TEXTARE A NAME="comments" ROWS="10"
COLS="34"></TEXTAREA></td></tr>
<td><br><inpu t type="submit" name="Submit" value="Submit"> </td>
<td><br>
<input type="reset" name="reset" value="Reset"></td></tr></table>
</form>
<!--end of the form -->
<!-- END THE COPYING HERE!!!!!!! -->
script. I am testing my PHP scripts on free server, which dosen't allow me
to send email letters from my website.
Please tell me if every thing is ok, if not please correct my mistake. Thank
you for your help.
This is: "contact_form.p hp"
<?
// This is the beginning of the PHP code
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$error_msg = "";
$msg = "";
if(!$email){
$error_msg .= "Your email \n";
}
if($email){
if(!eregi("^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\._\-]+\.[a-zA-Z]{2,4}", $email)){
echo "\n<br>That is not a valid email address. Please <a
href=\"javascri pt:history.back ()\">return</a> to the previous page and try
again.\n<br>";
exit;
}
$msg .= "Email: \t $email \n";
}
if($comments){
$msg .= "Comments: \t $comments \n";
}
$sender_email=" ";
if(!isset($name )){
if($name == ""){
$sender_name="W eb Customer";
}
}else{
$sender_name=$n ame;
}
if(!isset($emai l)){
if($email == ""){
$sender_email=" Customer@websit e.com";
}
}else{
$sender_email=$ email;
}
if($error_msg != ""){
echo "You didn't fill in these required fields:<br>"
.nl2br($error_m sg) .'<br>Please <a
href="javascrip t:history.back( )">return</a> to the previous page and try
again.';
exit;
}
$mailheaders = "MIME-Version: 1.0\r\n";
$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$mailheaders .= "From: $sender_name <$sender_email> \r\n";
$mailheaders .= "Reply-To: $sender_email <$sender_email> \r\n";
mail("your@emai l.com","Contact Us"stripslashes ($msg), $mailheaders);
header("Locatio n: http://yahoo.com/"); /* Redirect browser */
$myname = "Your Name Here";
$mymail = "your@email.com ";
$subject = "Thank you for your mail!";
$body = "Hi. This is an auto response to let you know that I've successfully
received your
email sent through my email form @ mywebsite.com. Thanks! I'll get back to
you
shortly.";
$headers = "Content-Type: text/plain; charset=us-ascii From: $myname
<$mymail> Reply-To: <$mymail> Return-Path: <$mymail> X-Mailer: PHP";
if ($email != "") { mail($email,$su bject,$body,$he aders); }
//This is the end of the PHP code
?>
And this is a simple "contact form" for the script.
<!-- BEGIN THE COPYING HERE!!!!!!! --><!-- beginning of the form -->
<form METHOD=POST ACTION="contact _form.php">
<table width="300" border="0" cellspacing="0" cellpadding="0" >
<tr><td>Name: </td><td> <I NPUT TYPE="text" NAME="name"></td></tr>
<tr><td>E-mail:</td><td> <I NPUT TYPE="text" NAME="email"></td></tr>
<tr><td valign="top">Co mments:</td><td><TEXTARE A NAME="comments" ROWS="10"
COLS="34"></TEXTAREA></td></tr>
<td><br><inpu t type="submit" name="Submit" value="Submit"> </td>
<td><br>
<input type="reset" name="reset" value="Reset"></td></tr></table>
</form>
<!--end of the form -->
<!-- END THE COPYING HERE!!!!!!! -->
Comment