1. The lists are not part of the <form> being submitted to sendmail.php.
2. You have misspelt sendmail.php in your forms action, causing the 404.
3. Happy new year
index.php
Code:
<html><head>
<title>Administration</title>
</head><body>
<table border="2" bordercolor="purple"><tr><td>
<b>Test Subscribe Email to List ></b>
<a href="subscribe.html">Go to Subscribe Page</a>.<br>
</td></tr></table>
<br>
<H1>Mailing List Admin Panel</H1>
<table cellspacing="20" border="2" bordercolor="green" >
<tr><td valign="top">
<b>Lists:</b>
</td>
<td>
<select name="List" size="7">
<option value="Email.lst" selected="selected">January list</option></select>
</td>
<td valign="top">
<b><a href="newlist.php">Make a new E-mail List.</a></b>
<br><a href="addnames.php">Add Single E-mails to a List</a>.
<br><a href="picklist.php">Edit/Delete E-mails from a List</a>.
<br><a href="data/log.txt">View the Sent Message Log File</a>.
<br><a href="autoresponder.php">View/Edit the Autoresponder</a>.
</td></tr>
</table>
<h3>Send an E-mail to a mailing List:</h3>
<form method="post" action="sendemail.php">
<table border="2" bordercolor="red"><tr><td>
<b>From E-Mail:</b>
<input type="text" name="From" size="40" value="">
<br><br />
<b>Subject:</b><input type="text" name="Subject" size="40">
</td></tr></table>
<br />
Type or paste your message below:
<br><textarea cols="40" rows="5" name="Body"></textarea>
<br><br>
<input type="submit" name="Submit" value="Send Mail">
</form>
<br>
</body></html>
Last edited by bionoid; 01-01-2012 at 10:41 AM.
Reason: Added the third thing
Ah, I see the problem now, you were using round brackets again to access the post data, when it should be square brackets []. You sure there was no drinking involved :
sendmail.php
Code:
<?php
$List = $_POST['List'];
$From = $_POST['From'];
$Subject = $_POST['Subject'];
$Body = $_POST['Body'];
$addresses = file("data/$List");
for ($index = 0; $index < count($addresses); $index++) {
mail(rtrim($addresses[$index]), $Subject, $Body, "From: $From\nReply-To: $From");
}
$myfile = fopen('data/log.txt', 'a');
fputs($myfile, $Subject . "\t" . date('dS of F Y h:i:s A') . "\t" . $List . "\n");
fclose($myfile);
?>
Your message was sent!
I checked your form and it's sending all the required fields now.
I do disappoint myself sometimes. The thought about changing the () to [] had crossed my mind but I failed to implement. My level of experience meant that I was afraid of wrecking something. I was brought up to believe that... if it is not broken, don't fix it! That can lead to a mental blockage sometimes when working on web pages.
Yes and great, the form is now working an I am receiving test emails. Thanks for helping to locate the breakage. I need another drink but not yet.
I am now going back to the autoresponder bit of the puzzel. I appologise for repeating myself here....
Firstly, When a visitor submits an email address it is written to a List using the writesubscription.php processor. (the writesubscription.php is something that I have introduced to deal with the subscribe form facility) I was of the opinion that a message would then be sent to the visitors email address from the autoresponder facility and that this would happen automatically after the visitor submitted the email address.!
The question now is, how is same activated?
The thanks.php php code as was part of the tutorial is like so:
PHP Code:
<html><head>
<title>Thanks You Page</title>
</head><body>
<?php
$Body = readfile("data/autoresponder.txt");
mail("$Email","Welcome to my mailing list!",
"$Body","From: Me\nReply-To: me@myaddress.com");
$myfile = file("data/mylist.lst");
$fh = fopen("data/mylist.lst","a");
for ($index=0; $index < count($myfile); $index++)
{
if ($Email != chop($myfile[$index]))
{fputs($fh,$myfile[$index]);}
}
fputs($fh,$Email."\n");
fclose($myfile);
?>
Thank you!
<br><br>
<a href="index.php">Back to Home Page</a>.
</body></html>
How might the thanks.php php code be activated bearing in mind that the form action on the subscribe.html page is writesubscription.php...?
I want to write the following in invisible text.... I tried adding the thanks.php php code into the writesubscription.php file but that only gives me a 500 error!
..........well almost invisible. Again you might be able to get me back on track!
This is the code that I have installed in what I now call process_sub.php.
It accounts for 1. //VALIDATE THE SUBMITTED EMAIL 2. //WRITE VALIDATED EMAIL TO LIST 3. //SEND AUTORESPONDER MESSAGE CONTROL
Parts 1 and 2 of the code works. When part 3 of the code is introduced it throws a 500 error.
PHP Code:
<html><head> <title>Write Subscribe to List....</title> </head><body> <br /> <?php
//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"); }
//SEEKING TO INSTALL THE AUTORESPONDER CODE HERE TO FUNCTION //AFTER VISITOR EMAIL HAS BEEN SUBMITTED, VALIDATED AND ADDED TO LIST. // This part of the code throws a 500 error....!
Bookmarks