www.webdeveloper.com
Page 3 of 3 FirstFirst 123
Results 31 to 37 of 37

Thread: Running Mail List Tutorial...!

  1. #31
    Join Date
    Dec 2011
    Location
    Centurion, South Africa
    Posts
    792
    Three things:

    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
    JavaScript: Learn | Validate | Compact

  2. #32
    Join Date
    Jul 2011
    Location
    Irish Republic
    Posts
    64
    Thanks. Have corrected the sendmail.php name and altered the code on index.php as indicated. Now getting a 500 error on submission of test message.

  3. #33
    Join Date
    Dec 2011
    Location
    Centurion, South Africa
    Posts
    792
    Lol, I didn't correct any html code, I just pointed it out. I see your List is still outside of the form. I will suggest a change this time:

    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>
    <form method="post" action="sendmail.php">
    <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>
    <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>
    I moved the <form> element above the List items.
    JavaScript: Learn | Validate | Compact

  4. #34
    Join Date
    Jul 2011
    Location
    Irish Republic
    Posts
    64
    Sorry, must be missing something here. Still suffering from that 500 error! I believe that List detail is now inside the form tags.

  5. #35
    Join Date
    Dec 2011
    Location
    Centurion, South Africa
    Posts
    792
    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.
    JavaScript: Learn | Validate | Compact

  6. #36
    Join Date
    Jul 2011
    Location
    Irish Republic
    Posts
    64
    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!

  7. #37
    Join Date
    Jul 2011
    Location
    Irish Republic
    Posts
    64
    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"); 
            }        
            
        
    //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 "\n"); 
            
    fclose($fh); 
        } else { 
            
    $myfile fopen("data/$List""w"); 
            
    fputs($myfile$Email "\n"); 
            
    fclose($myfile); 
        }
        
    //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....!


        //3.  SEND AUTORESPONDER MESSAGE    CONTROL
        
    $From    $_POST['From'];         
        
    $Body    $_POST['Body'];
        
        
    $Body =  readfile("data/autoresponder.txt");        
        
    mail("$Email","Welcome to my mailing list.!",
        
    "$Body","From: Author of Mail\nReply-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."\n");
        
    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>
    Is there a workout to get the autoresponder to work ?
    Last edited by webiter; 01-05-2012 at 06:58 PM. Reason: Added sentence

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles