Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Scripts -->
- <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function() {
- $('#signup').submit(function() {
- $("#success-message").html("Adding your email address...");
- $.ajax({
- url: 'inc/store-address.php', // proper url to your "store-address.php" file
- data: $('#signup').serialize() + '&ajax=true',
- success: function(msg) {
- $('#success-message').html(msg);
- }
- });
- return false;
- });
- });
- </script>
- </head>
- <body>
- <!-- Video -->
- <div class="hero">
- <div class="hero_background" date-native-currency="USA" aria-hidden="true">
- <video poster="image/black.png" autoplay="true" muted="" loop>
- <source src="videos/youtube.mp4" type="video/mp4">
- <source src="videos/youtube.webm" type="video/webm">
- </video>
- </div>
- </div>
- <!-- Email and Full Name -->
- <div class="subscription_box cf">
- <div class="container">
- <form id="signup" role="form" action="index.html" method="get">
- <input class="text" id="fname" type="text" name="fname" placeholder="Full Name">
- <br>
- <input class="email" id="email" type="email" name="Email" placeholder="me@gmail.com">
- <br>
- <input class="button" id="submit" type="submit" value="Subscribe">
- <span id="success-message" class="ajax_response"></span> <!-- This is the success message -->
- </form>
- </div>
- </div>
- <?php // for MailChimp API v3.0
- include('MailChimp.php'); // path to API wrapper downloaded from GitHub
- use DrewMMailChimpMailChimp;
- function storeAddress() {
- $key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxkey";
- $list_id = "xxxxxxID";
- $merge_vars = array(
- 'FNAME' => $_POST['fname']
- );
- $mc = new MailChimp($key);
- // add the email to your list
- $result = $mc->post('/lists/'.$list_id.'/members', array(
- 'email_address' => $_POST['email'],
- 'merge_fields' => $merge_vars,
- 'status' => 'pending' // double opt-in
- // 'status' => 'subscribed' // single opt-in
- )
- );
- return json_encode($result);
- }
- // If being called via ajax, run the function, else fail
- if ($_POST['ajax']) {
- echo storeAddress(); // send the response back through Ajax
- } else {
- echo 'Method not allowed - please ensure JavaScript is enabled in this browser';
- }
Add Comment
Please, Sign In to add comment