Hi-
I'm just learning php and I've been attempting to write code that will provide an auto-reply when visitors sign up for a mailing list. The form and php code work fine when it comes to adding the record. All the input information turns up in the database as it should. The problem seems to be with the auto reply facet as no return email is generated. If someone can tell me where I've gone wrong I would appreciate it. Here's the code:
<!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 http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<meta http-equiv="REFRESH" content="0; URL=http://www.mywebsite/thanks.htm" />
</head>
<body>
<?php
$Name=$POST['Name'];
$EMail=$POST['EMail'];
$connection=mysql_connect ("database location",
"database name", "password") or die ('I cannot
connect to the database.');
mysql_select_db ("database name",$connection) or die(
"Unable to select database");
$query = "INSERT INTO table name (ID, Name,
EMail) VALUES ('', '$Name', '$EMail')";
mysql_query($query);
mysql_close();
$to = $EMail;
$from = "my email address";
$headers = "FROM:".$from."\r\n";
$headers .= "Reply-To:".$from."\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$return_path = $from;
$subject = "subject here";
$message = "Hi ". $Name;
$message .= "<br>Thank you for subscribing to the our mailing list. You'll soon be receiving
fast breaking news as well as special events and more.
To change your subscription:
If you'd like your email updated or changed for any reason, please advise us and we will be happy to oblige.
Or, if you no longer wish to receive e-mail updates from us, you can unsubscribe by returning any email update
with the subject line \"unsubscribe\".";
mail($to,$subject,$message,$headers,"-f".$return_path);
?>
</body>
</html>
Thanks in advance.