Seeking to get this subscribe email/validate email/autorespopnder message to subscriber script, working so that I can install within a website.
It is not a large machine and I only want a facility to manage at max 400 - 600 emails without having to use the mySQL apparatus.
I have same set up and running to a extent at this link location
Workings of the script are as follows:
1. Visitor submits an email into a website field.
2. The email is validated with javascript/php.
3. The validated email is added to a Master list.
4. An on screen Thank You notice is presented to the visitor.
5. Autoresponder sends a presaved message to the visitors email.
6. Another visitor can repeat the above and the list grows.
7. I can then copy and paste the Master list
entries on a monthly basis to the sublists Jan, Feb, Mar, etc.
8. I can then tailor monthly messages by selecting from the various email sublists.
Some problems that I am aware of currently
1. A blank line is being saved in the Master list when a email is submitted. Not sure if same is of consequence but I do not know why it is occuring.
2. Autoresponder is sending a email to my email address but it does not present the message - only the number (the size of the file) in the message. See image of email attached.
3. I want to be sure that the autoresponder script is only selecting the last email entry from the Master list each time.
4. The Thank You message and the autoresponder message currently present on the screen as the process completes. Only the Thank You message should present pon screen.
The //VALIDATE THE SUBMITTED EMAIL & the //WRITE VALIDATED EMAIL TO LIST parts of this page code seems to work fine on their own bar the apparant saving of blank lines to the master list!
The //SEND AUTO MESSAGE TO VISITOR not working to requirements!
The following is the code that forms the processor?
PHP Code:
<html><head>
<title>Write to List/Send Auto....</title>
</head><body><center>
<table cellspacing="10" border="2" bordercolor="blue"><tr><td><center>
<?php
//VALIDATE THE SUBMITTED EMAIL
$Email = htmlspecialchars($_POST['Email']);
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$Email)) {
echo '<br /><a href="http://www.postbox.webitry.net/subscribe.html" onClick="history.go(-1)"><h3>> Go Back to Email Submit Form <</h3></a><br />';
die("<h3>and enter a valid Email Address..!</h3>");
}
//WRITE VALIDATED EMAIL TO LIST
$List = $_POST['List'];
if (file_exists("data/$List")) {
$myfile = file("data/$List");
$fh = fopen("data/$List", "w");
for ($index = 0; $index < count($myfile); $index++) {
if ($Email != rtrim($myfile[$index])) {
fputs($fh, $myfile[$index]);}
}
fputs($fh, $Email . "\n");
fclose($fh);
} else {
$myfile = fopen("data/$List", "w");
fputs($myfile, $Email . "\n");
fclose($myfile);
}
//SEND AUTORESPONDER MESSAGE TO VISITOR
//$From = $_POST['From'];
$From = 'p-------@gmail.com';
$Body = readfile("data/autoresponder.txt");
mail("$Email","Welcome to my mailing list.!", "$Body","From: $From\nReply-To: $From");
$addresses = file("data/$List");
$fh = fopen("data/$List","a");
for ($index=0; $index < count($addresses); $index++)
{
if ($Email != trim($addresses[$index]))
{fputs($fh,$myfile[$index]);}
}
fputs($fh,$Email."\n");
//fclose($myfile);
?>
<br><br>
<!--THE FOLLOWING IS THE ON SCREEN MESSAGE THAT THE VISITOR RECEIVES-->
Thank you for subscribing to our E-mail List!
<br><br>
<a href="index.php">Back to Home Page</a>.
<br /><br /></center></td></tr></table></center></body></html>
Any advice greatly appreciated.
Bookmarks