This is the code that I have installed in what I call process_sub.php. which is demonstrated at this TEST LINK
The page accounts for the following processes on a simple submit email form: Part 1.//VALIDATE THE SUBMITTED EMAIL Part 2. //WRITE VALIDATED EMAIL TO LIST Part 3.//SEND AUTORESPONDER MESSAGE
Parts 1 and 2 of the code works.When part 3 of the code is introduced it throws a 500 error.
[SIZE=3]The process I seek to manage is as follows. A visitor submits an email which is validated and entered to, and stored in a flatfile List. I am seeking also that an autoresponse is forwarded to the submitters email address.
I seek to find if I am on the right track in Part 3 of the code! Any direction / resolution greatly appreciated.
[/SIZE]
<html><head>
<title>Write Subscribe to List....</title>
</head><body>
<br />
<?php
//Part 1. VALIDATE THE SUBMITTED EMAIL
$Email = $_POST['Email'];
$Email = htmlspecialchars($_POST['Email']);
if (!preg_match("/([\\w\\-]+\\@[\\w\\-]+\\.[\\w\\-]+)/",$Email)) {
die("Please enter a valid email address....!<br /><br />Use the Go Back Button to return to the SUBMIT EMAIL Form");
}
//Part 2. 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 . "\
");
fclose($fh);
} else {
$myfile = fopen("data/$List", "w");
fputs($myfile, $Email . "\
");
fclose($myfile);
}
//SEEKING TO INSTALL THE AUTORESPONDER CODE HERE TO FUNCTION
//AFTER VISITOR EMAIL HAS BEEN SUBMITTED, VALIDATED AND ADDED TO LIST.
// This Part 3 of the code when introduced throws a 500 error....?
//Part 3. SEND AUTORESPONDER MESSAGE
$From = $_POST['From'];
$Body = $_POST['Body'];
$Body = readfile("data/autoresponder.txt");
mail("$Email","Welcome to my mailing list.!",
"$Body","From: Author of Mail\
Reply-To: home@gmail.com");
$addresses = file("data/$List");
$addresses = file("data/Email.lst");
$fh = fopen("data/Email.lst","a");
for ($index=0; $index < count($addresses); $index++)
{
if ($Email != trim($addresses[$index]))
{fputs($fh,$myfile[$index]);}
}
fputs($fh,$Email."\
");
fclose($myfile);
?>
<br><br>
Thank you for subscribing to our E-mail List!
<br><br>
<a href="index.php">Back to Home Page</a>.
</body></html>
Now got error logging going at [U][B]Test Position[/B][/U].
Script lines in question on page process_sub.php numbered as attached image.
The following is extracted from the error_log.txt
Notice: Undefined index: $From in C:\CustomerData\webspaces\webspace_00156450\wwwroot\postbox.webitry.net\process_sub.php on line 42
The following is the current configuration of line 42$From = $_POST[‘$From’];
Guidence/direction needed to get this issue resolved…!
The following is also recorded in the error_log.txt
[09-Jan-2012 19:36:39] PHP Notice: Undefined variable: List in C:\CustomerData\webspaces\webspace_00156450\wwwroot\postbox.webitry.net\editnames.php on line 11
The following is the content of line 11<?php echo $List ?>.
Again guidence/direction needed to get this issue resolved…!
The following is the code for the editnames.php page.
<html><head><title>Edit Maillist addresses</title></head><body>
<table cellspacing="10" border="2" bordercolor="blue" ><tr><td>
<form method="post" action="writenamefile.php">
<b>Editing E-mail details for List...</b><br />
<?php echo $List ?>. <!--SHOULD THERE BE ADDITIONAL LIST SELECTION HERE..?-->
Fix an address by editing <br />in place, or remove an address<br />
by deleting the WHOLE line altogether.<br />
<b>No blank LINES or SPACES allowed! </b>
<br><br><textarea cols="27" rows="20" name="Body">
<?php
$List = $_POST['List'];
if (file_exists("data/$List"))
{readfile("data/$List");}
?>
</textarea>
<br>
<input type="hidden" name="List" value="<?php echo $List ?>">
<input type="submit" name="submit" value="Save This List">
</form>
<a href="addnames.php">Add names to the list</a>.
<br><a href="data/log.txt">View Send Log</a>.
</td></tr></table></body></html>
Sorry spikeZ I may not have framed my question all that well.
Line 42 is as you have indicated $From = $_POST[‘From’]; and it is presenting the error - Notice: Undefined index: $From in C:\CustomerData\webspaces\webspace_00156450\wwwroot\postbox.webitry.net\process_sub.php on line 42
The line 11 is a different page and a different issue. Perhaps I should not have presented the line 11 issue here.
Thanks and much appreciated, I have got rid of the two errors that were presenting. I edited line as follows: $From = ‘myemail@gmail.com’;
I note the following items arising that I could do with some direction on:
[B]1.[/B] When the email arrives from the autoresponder it only presents with the [B]number[/B] of characters in the message! (ie not the message but just a numerical value as in 145) . Does this mean that the [COLOR="#A52A2A"]$Body = readfile("data/autoresponder.txt");[/COLOR] line of the code is in some way faulty?
[B] 2. [/B] How might I go about hiding the autoresponder message from the visitor? All I want the visitor to see on screen is the [B]Thank you for subscribing to our E-mail List![/B] and the Go Back button.