Processing a subscription form with POST method?

I am trying to integrate a ‘subscribe to newsletter’ feature on my wordpress blog

Users just need to enter their name and email address, hit subscribe. This is then supposed to send me an email and I add them to the mailing list.

I activated the WP SMTP Mail plugin and entered in the relevant email server information to enable WordPress to send emails, asked WordPress to send me a test message and this worked.

Now I want to receive an email whenever someone fills in their name & email and hit subscribe.

If I do this at the moment it just does nothing, it re-loads the page without sending an email.

I have attached my code below, can anyone help me out here?

Code for the signup form sidebar.php – This is not a plugin.

 <form action="newsletter_signup.php" method="post">
     <p><input class="full" type="text" name="name" placeholder="Your name*"></p>
     <p><input class="full" type="email" name="Email" placeholder="Your email address*"></p>
     <p><input type="submit" class="sub-btn" value="Subscribe"></p>
 </form>

The code in the newsletter_signup.php file:

<?php
    require_once('wp-load.php');
    $name = $_POST['name'];
    $Email = $_POST['Email'];
    $to = '[email protected]';      
    wp_mail($to, $name, 'From: ' . $Email);
    echo 'Your request Has Been Sent, Thank You. ';
?>

2 Answers
2

This solution is based on a couple of WPMU Dev plugins: PopUp Pro and Mailchimp Integration. If you are WPMU Dev member then download and install them either from their Project pages or via the WPMU Dev dashboard in your WordPress admin interface.
Most of the effort is in creating a custom style for the popup. The Mailchimp Integration plugin simply provides a shortcode that can be added to the body of the popup via a TinyMCE button but we’ll cover all this later.
The first step, after installing the plugins is to configure the Mailchimp Integrationplugin.

Leave a Comment