我只是想将mailchimp代码集成到我的php表单中现在发送电子邮件但我有一个复选框如果用户想要新闻和更新,可以选中或取消选中
<div class="checkbox">
<label>
<input type="checkbox" id="emailUpdates" name="emailUpdates" value="Yes">
Please keep me informed of product updates and news
</label>
</div>
PHP <?php
// SUBSCRIBE TO MAILING LIST OPTION - ADD TO MAILCHIMP USING API
if ($_POST['emailUpdates'] == 'Yes')
{
// Include Mailchimp API class
require_once('MCAPI.class.php');
// Your API Key: http://admin.mailchimp.com/account/api/
$api = new MCAPI('feaf699f7a15c1ca27f6903152d4a3f1-us3');
// Your List Unique ID: http://admin.mailchimp.com/lists/ (Click "settings")
$list_id = "69010111da";
// Variables in your form that match up to variables on your subscriber
// list. You might have only a single 'name' field, no fields at all, or more
// fields that you want to sync up.
$merge_vars = array(
'FNAME' => $_POST['first_name'],
'LNAME' => $_POST['last_name']
);
// SUBSCRIBE TO LIST
if ( $api->listSubscribe($list_id, $_POST['email'], $merge_vars) === true ){
$mailchimp_result = 'Success! Check your email to confirm sign up.';
} else {
$mailchimp_result = 'Error: ' . $api->errorMessage;
}
}
?>
在我的本地主机上,它写的是
注意:未定义的索引:emailUpdates在C:xampphtdocskinectapicontact.php第98行
我的代码有什么问题?任何帮助吗?
谢谢!
当你的表单submit name="emailUpdates"
没有被检查,所以它返回这种类型的数组Undefined index: emailUpdates
,意味着数组键不包含emailUpdates
。$_POST['emailUpdates']