我正在使用MailChimp中的“嵌入式表单”选项将新的订阅者信息发送到我的MailChimp订阅者列表。我正在尝试做的是将这些数据发送到我的网站的MySQL数据库。
MailChimp提供的表格是:
<div id="mc_embed_signup">
<form action="http://my_example_site.com/subscribe/post?u=[my_api_key]&id=[my_list_id]" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<h2>Subscribe to our mailing list</h2>
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group">
<label for="mce-EMAIL">Email Address <span class="asterisk">*</span></label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name </label>
<input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>
<div class="mc-field-group">
<label for="mce-LNAME">Last Name </label>
<input type="text" value="" name="LNAME" class="" id="mce-LNAME">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
<div style="position: absolute; left: -5000px;"><input type="text" name="[my_api_key]" tabindex="-1" value=""></div>
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</form>
</div>
我不仅要将此数据发送到MailChimp,还要将这些新数据插入到我的MySQL数据库中。
我原本想这样的事情:
action = "updateList.php"
。这个文件将我的插入数据导入MySQL。然后以某种方式将数据转发给MailChimp ?? updateList.php:
<?php
require "config.php"; /* MySQL database connection details */
if (isset($_POST['EMAIL'])) { $email = $_POST['EMAIL']; }
if (isset($_POST['FNAME'])) { $fname = $_POST['FNAME']; }
if (isset($_POST['LNAME'])) { $lname = $_POST['LNAME']; }
if (strlen($email)>0 && strlen($fname)>0 && strlen($lname)>0) {
$date_time = date("Y-m-d H:i:s");
$result = "INSERT INTO subscribers (EMAIL, FNAME, LNAME, DATE_TIME) VALUES (:email, :fname, :lname, :date_time)";
$statement = $db->prepare($result);
$statement->bindValue(":email", $email);
$statement->bindValue(":fname", $fname);
$statement->bindValue(":lname", $lname);
$statement->bindValue(":date_time", $date_time);
$stmt = $statement->execute();
/****** INSERT CODE TO FORWARD THE DATA TO MAILCHIMP?? *******/
}