SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Mentor silver trophybronze trophy
    alabamaseo's Avatar
    Join Date
    Dec 2012
    Location
    Birmingham, AL
    Posts
    203
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)

    Problem Syncing Newsletter Submit Form- Mailchimp

    Hello,

    I am trying to set up a newsletter sign up form which collects only a user's email address and submits it be stored with Mailchimp.

    I am using a modified version of the example at Sitepoint, but I can not get it to work for some reason. Can someone please help me troubleshoot this?

    Form:

    HTML Code:
    <head>
    <script type="text/javascript" src="js/prototype.js"></script> 
    <script type="text/javascript" src="js/mailingList.js"></script>
    </head>
    
    
    <form id="signup" action="<?=$_SERVER['PHP_SELF']; ?>" method="get">
    <table id="sign-up-table">
    <tbody>
    <tr>
    <td id="sign-up-email" style="vertical-align: middle;"><center> <label for="email">Join our Mailing List to Stay Current on the Latest Healthcare News:<span id="response">
    					<? require_once('inc/store-address.php'); if($_GET['submit']){ echo storeAddress(); } ?>
    				  </span>
    			  </label></center></td>
    <td><input class="rounded-corners" id="email-input" type="text" maxlength="80" name="email" size="23" value="Enter Email..." /></td>
    <td>
    <input type="submit" id="new-button" value="Sign Up" name="sumbit" /></td>
    </tr>
    </tbody>
    </table>
    </form>

    PHP files:

    PHP Code:
    <?php


    function storeAddress(){
        
        
    // Validation
        
    if(!$_GET['email']){ return "No email address provided"; } 

        if(!
    preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$/i"$_GET['email'])) {
            return 
    "Email address is invalid"
        }

        require_once(
    'MCAPI.class.php');
        
    // grab an API Key from http://admin.mailchimp.com/account/api/
        
    $api = new MCAPI('ea829e951391385d5ff9ce258a4a017c-us7');
        
        
    // grab your List's Unique Id by going to http://admin.mailchimp.com/lists/
        // Click the "settings" link for the list - the Unique Id is at the bottom of that page. 
        
    $list_id "b10826d985";

        if(
    $api->listSubscribe($list_id$_GET['email'], '') === true) {
            
    // It worked!    
            
    return 'Success! Check your email to confirm sign up.';
        }else{
            
    // An error ocurred, return error message    
            
    return 'Error: ' $api->errorMessage;
        }
        
    }

    // If being called via ajax, autorun the function
    if($_GET['ajax']){ echo storeAddress(); }
    ?>
    There was another php file which can be found at http://truckermarketplace.com/inc/MCAPI.class.php


    Thanks in Advance.
    Levy's Fine Jewelry- buyers and sellers of modern, antique, and estate jewelry

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,301
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Off Topic:

    Is there a reason why you aren't using the form code that MailChimp provides? Those forms are so simple that I prefer to use those.

  3. #3
    SitePoint Mentor silver trophybronze trophy
    alabamaseo's Avatar
    Join Date
    Dec 2012
    Location
    Birmingham, AL
    Posts
    203
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    Can I design a custom HTML/CSS form to use? This is going on a landing page, so the styling is very important.
    Levy's Fine Jewelry- buyers and sellers of modern, antique, and estate jewelry

  4. #4
    SitePoint Mentor silver trophybronze trophy
    alabamaseo's Avatar
    Join Date
    Dec 2012
    Location
    Birmingham, AL
    Posts
    203
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    I just looked into it, and I think that is going to work. Thanks a lot Ralph!
    Levy's Fine Jewelry- buyers and sellers of modern, antique, and estate jewelry

  5. #5
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,301
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by alabamaseo View Post
    Can I design a custom HTML/CSS form to use?
    Absolutely. They just give you the basic form with the name attributes etc. that will work with their system. The styling is 100% up to you.

    Admittedly, I've not had much to do with MailChimp, using CampaignMonitor instead, but I think they are much alike in this regard.


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
  •