Problem Syncing Newsletter Submit Form- Mailchimp


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?


<script type="text/javascript" src="js/prototype.js"></script> 
<script type="text/javascript" src="js/mailingList.js"></script>

<form id="signup" action="<?=$_SERVER['PHP_SELF']; ?>" method="get">
<table id="sign-up-table">
<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(); } ?>
<td><input class="rounded-corners" id="email-input" type="text" maxlength="80" name="email" size="23" value="Enter Email..." /></td>
<input type="submit" id="new-button" value="Sign Up" name="sumbit" /></td>

PHP files:


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"; 

	// grab an API Key from
	$api = new MCAPI('ea829e951391385d5ff9ce258a4a017c-us7');
	// grab your List's Unique Id by going to
	// 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.';
		// 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

Thanks in Advance.

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.

Can I design a custom HTML/CSS form to use? This is going on a landing page, so the styling is very important.

I just looked into it, and I think that is going to work. Thanks a lot Ralph!

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. :slight_smile:

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