<?php

    require_once 'mailchimp.class.php';
    require_once 'config.php';
	
    $api = new MCAPI($apikey);

    $merge_vars = array(
	    'FNAME'=> $_POST["firstname"], 
	    'LNAME'=> $_POST["lastname"], 
	    'EMAIL'=> $_POST["useremail"], 		           
    );

    $retval = $api->listSubscribe( $listId, $user_email, $merge_vars );

    if ($api->errorCode){
	    echo '<div class="newsletter-error-message">'.$api->errorMessage.'</div>';
    } 
	else {
	    echo '<div class="newsletter-success-message">Subscribed successfully - look for the confirmation email</div>';
    }
?>
