Jump to content

Adapting mailchimp subscribe code


ohboyatoytruck

Recommended Posts

Hi there,

 

Mailchimp supplies web form code for adding subscribers from a web page. I need to adapt this code so that instead of form fields, php variables get passed on to mailchimp. This is because the form fields are part of another form and you can have forms in forms. The variables I need to pass to Mailchimp a rev as follows:

 

$firstname

$lastname

$email

 

These variables have been passed from an earlier form via $_POST with similar names e.g. firstName, lastName and email.

 

The mailchimp form code is below with the id numbers replaced with XXX, YYY and ZZZ

 

<form action="//asn.us7.list-manage.com/subscribe/post?u=XXX;id=YYY" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>

<h2>Subscribe to our mailing list</h2>
<div class="mc-field-group">
<label for="mce-EMAIL">Email Address*</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>    <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
    <div style="position: absolute; left: -5000px;"><input type="text" name="ZZZ" tabindex="-1" value=""></div>
    <div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</form>
 
All assistance gratefully received.
Link to comment
https://forums.phpfreaks.com/topic/292995-adapting-mailchimp-subscribe-code/
Share on other sites

MailChimp has an api for doing exactly this. Have your code send a subscribe request to MailChimp instead of using the form method.

Im sorry but I don't know how to send a subscribe request to MAilchimp - the code in the link you provided is beyond me

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.