index.php code:
<form role="form" action="form.php" method="post">
<input type="email" id="emailSub" placeholder="Enter your Email Adress" size="30">
<button type="button" id="submit" class="btn">
</form>
form.php code:
<?php
include_once 'MailChimp.php';
$alertclass = 'alert-warning';
$msg = '';
$email = '';
if (isset($POST['submit'])) {
if (empty($_POST['emailSub'])) {
$msg = 'Please enter a email address.';
} else {
$email = filter_var($_POST['emailSub'], FILTER_SANITIZE_EMAIL);
$mc = new MailChimp('MY-API-KEY');
$result = $mc->call('lists/subscribe', array(
'id' => 'MY-LIST-ID',
'email' => array('email'=>$email),
'double_optin' => true,
'update_existing' => false,
'replace_interests' => false,
'send_welcome' => false
)
);
if (!empty($result['euid'])) {
$msg = 'Thanks, please check your mailbox and confirm the subscription.';
$alertclass = 'alert-success';
} else {
if (isset($result['status'])) {
switch ($result['code']) {
case 214:
$msg = 'You\'re already a member of this list.';
break;
default:
$msg = 'An unknown error occurred.';
$alertclass = 'alert-error';
break;
}
}
}
echo $msg;
}
}
?>
I upload it to a server who supports a version of 5.4 PHP so its should work, but it doesnt. Nothing happened, no adding subscribes to my mailchimp list and even not a messages or something. and I dont know why. Any ideas?