SitePoint Sponsor

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 25 of 53
  1. #1
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Notice: This is a discussion thread for comments about the SitePoint article, Use AJAX and PHP to Build your Mailing List.
    __________

    Is there a link to a demo?

  2. #2
    SitePoint Enthusiast earthlingzed's Avatar
    Join Date
    Jul 2004
    Location
    athens, ga
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code archive is at the top of the article to set it up on your server and try out. You'll just need to set up the table in your MySQL database.

    There is also now a demo you can try out. Demo Mailing List Sign Up

  3. #3
    SitePoint Enthusiast M.Mahgoub's Avatar
    Join Date
    Oct 2003
    Location
    Overseas
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why the code doesn't prevent duplication! users can submit their emails couple of times!

  4. #4
    SitePoint Enthusiast earthlingzed's Avatar
    Join Date
    Jul 2004
    Location
    athens, ga
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can prevent sign up duplicates by preceding the INSERT statement with a SELECT looking for the address in the database. You can use a conditional to check if the SELECT statement returned any records. If so, we can return a message letting the user know they've already signed up. Here is what that might look like:


    PHP Code:
    $addresscheck mysql_query("SELECT * FROM mailinglist WHERE email='" $address "'");
          
    if( 
    mysql_num_rows($addresscheck) != ){
        
    $message "Address already signed up";
    }else{
        
    // Insert email address into mailinglist table 
        
    $result mysql_query("INSERT INTO mailinglist SET email='" $address "'");
        if(
    mysql_error()){
            
    $message "<strong>Error</strong>: There was an error storing your email address.";
        } else {
            
    $message "Thanks for signing up!";
        }
              
    // End Check for Duplicate Address 
    Aarron Walter
    -----------------------------------------------
    Interactive Designer
    http://aarronwalter.com

  5. #5
    SitePoint Addict Quaint's Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or check this out: http://dev.mysql.com/doc/refman/5.0/en/replace.html

    You could use REPLACE instead of insert, to automatically check for duplicates.. You'd have to make the email field UNIQUE though (which isn't hard..)

  6. #6
    SitePoint Zealot rushy2uk's Avatar
    Join Date
    May 2005
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice article, thanx!

  7. #7
    SitePoint Enthusiast earthlingzed's Avatar
    Join Date
    Jul 2004
    Location
    athens, ga
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are interested in extending this mailing list sign up system to receive more user input, or even apply these concepts to other contexts, you may find this helpful: Extending the Ajax Mailing List Sign Up System
    Aarron Walter
    -----------------------------------------------
    Interactive Designer
    http://aarronwalter.com

  8. #8
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code download gives a 404

  9. #9
    Nate K
    SitePoint Community Guest
    I think the example was a good one. Two issues I had:

    1. The storeAddress.php uses short tags to open. I have them disabled on my server, therefore I had to add the 'php'. The other pages used 'php'.
    2. Justfying a large prototype library for a few small functions. It could have been avoided by using some DOM methods. I just didn't think prototype was completely necessary for the small task.

    Other than that, I liked it :)

  10. #10
    SitePoint Enthusiast earthlingzed's Avatar
    Join Date
    Jul 2004
    Location
    athens, ga
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    File size is a common criticism of Prototype, and I think a valid one. I like it for this purpose because it greatly simplifies the potential complexity of wrangling Ajax calls/responses, especially if you are new to it. I am also making an assumption that it would be used for other tasks in a site as well.

    It's great to question the use of a framework like this, though, rather than getting caught up in its hype, because a 52k addition to a page for a simple task may not fit the bill for your target audience and site goals.
    Aarron Walter
    -----------------------------------------------
    Interactive Designer
    http://aarronwalter.com

  11. #11
    SitePoint Addict dotancohen's Avatar
    Join Date
    Aug 2005
    Location
    Haifa
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The latest Prototype is 46 kb, and each new version seems to be about 2 kb lees than the previous. I think that this is a very reasonable amount of code for the work that it does, and I'm pretty certain that it could be reduced to 40kb if the application demanded it, with the removal of comments and whitespace.

    Congratulations to the Prototype developers, and to Aarron and all at sitepoint for the info.

  12. #12
    SitePoint Enthusiast
    Join Date
    May 2005
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My Javascript file includes 6 ajax functions, including login/logout and it's only 3kb in size.

  13. #13
    3stripe
    SitePoint Community Guest
    Nice script!

    Am I right in thinking it doesn't check for duplicate email addresses?

  14. #14
    SitePoint Addict dotancohen's Avatar
    Join Date
    Aug 2005
    Location
    Haifa
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As I've expanded the form to include other fields, I'd like to use Prototype's Form.serialize to make the variables. But when I replace this:
    Code:
    var pars = 'address=' + escape($F('address'));
    with this:
    Code:
    var pars = Form.serialize(addressForm)
    then the form submits to wherever is specified in the action attribute. Why is that, and how can I work around it?

    @bas: I'd love to see that file. Mind sharing it?

    Thanks in advance.

    Dotan
    . Have a question?
    . . What Is Firefox?
    . . . . What Is Open Office?
    . . . . . . What Is What?

  15. #15
    SitePoint Member
    Join Date
    Mar 2006
    Location
    Glasgow, UK
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Regarding preventing duplicates, I saw the mention of this above.

    But how would you impliment this on the storeAddress.php code exactly?

    It keeps giving me errors. (eg
    Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/.canicula/jamesgreig/sneakergeeks.com/inc/storeAddress.php on line 9)

  16. #16
    Ritesh Jaiswal
    SitePoint Community Guest
    Articles and examples in 'sitepoint' is really very helpful in self learning and using then in our own business. The latest technologies used will surely enhance the knowledge base required for an individual to grow

  17. #17
    SitePoint Guru
    Join Date
    Nov 2001
    Location
    Fort Lauderdale
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would anyone be able to point me into the right direction of adding the following three functionalities to this list:

    1. Send a confirmation email to the user to confirm their registration to the mailing list.

    2. Unsubscribe Function along with confirmation.

    3. Actually sending out emails to the users that signed up. ie: using the mailing list to send out newsletters.

  18. #18
    SitePoint Enthusiast earthlingzed's Avatar
    Join Date
    Jul 2004
    Location
    athens, ga
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    4Seen, my recommendation to achieve all of the functionality you are looking for is to tie in to a mailing list service. Mail Chimp is the one I personally like best, and they have an API along with a PHP class to simplify the process. To learn more you can check out http://www.mailchimp.com/resources/g...iber_api.phtml

    You can use this Ajax approach to send the sign up to Mail Chimp rather than store it on your server in a database.
    Aarron Walter
    -----------------------------------------------
    Interactive Designer
    http://aarronwalter.com

  19. #19
    garwin
    SitePoint Community Guest
    is it possible to do this with another mailing list script?

  20. #20
    SitePoint Member
    Join Date
    Jan 2007
    Location
    Tehran
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it works very good
    thank you Aarron

    Regards,
    Nima Fatemi

  21. #21
    SitePoint Member
    Join Date
    Mar 2006
    Location
    Glasgow, UK
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've written a quick page with (very basic) security, that lists all of your current subscribers.

    It was worth doing to save logging into phpMyAdmin each time I wanted to check this!

    I'm a php/mysql novice so interested to hear your constructive criticism on this

    PHP Code:
    <?php
    /*
    Author: 3stripe
    URL: www.3stripe.net
    An addition to the code for the article "Use Ajax and PHP to Build Your Mailing List"
    by Aarron Walter (aarron@aarronwalter.com), which will list subscribers to your mailing list, and has some basic password protection to keep this data from prying eyes
    http://www.sitepoint.com/article/use-ajax-php-build-mailing-list
    */
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      <head>
        <title>Who has signed up?</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      </head>
      <body>
      
    <?php
    // Define your username and password
    $username "insertyourusernamehere";
    $password "insertyourpasswordhere";
    if (
    $_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {
    ?>


    <!-- Login form -->
    <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
        <p><label for="txtUsername">Username:</label>
        <input type="text" title="Enter your Username" name="txtUsername" /></p>
        <p><label for="txtpassword">Password:</label>
        <input type="password" title="Enter your password" name="txtPassword" /></p>
        <p><input type="submit" name="Submit" value="Login" /></p>
    </form>
    <!-- Login form ends -->

    <?php
    }
    else {
    ?>


    <!-- Protected content -->
    <p>Current subscribers:</p>
    <?php
    require_once("inc/dbConstants.php");
    // Connect to database
    $con mysql_connect(DBHOST ,DBUSERDBPASS);
    mysql_select_db(DBNAME$con);
    // Query mailinglist table 
    $result mysql_query("SELECT * FROM mailinglist");
    if(!
    $result) die("<h1>Query Failed :(</h2>");
    echo 
    "<ol>";

    while(
    $row mysql_fetch_row($result)) {
        echo 
    "<li>" $row[1] . '</li>';
    }

    echo 
    "</ol>";

    ?>

    <!-- Protected content ends -->
    <?php
    }
    ?> 

      </body>
    </html>
    Last edited by 3stripe; Feb 11, 2007 at 09:37.

  22. #22
    Moonwalker
    SitePoint Community Guest
    Very nice. Thank you very much for this. I have only one question though: When the address is stored, is it possible to clear the text field?

    Thx in advance.

    Cheers.

  23. #23
    Ashimema
    SitePoint Community Guest
    Beautifully written tutorial, thankyou for showing the in leads into AJAX. Although I think an error for duplicate addresses would be useful addition to the script. My next step I think will be to come up with a unsubscribe system.

  24. #24
    james
    SitePoint Community Guest
    Great. Now, is there an easy way to integrate a confirmation e-mail?

  25. #25
    SitePoint Member
    Join Date
    Aug 2003
    Location
    California
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does anyone have a method for allowing people to unsubscribe and to check for duplicates?

    Thanks in advance.


Bookmarks

Posting Permissions

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