1

I have created this widget function to show a subscription form but from here i am not able to get the the values of input fields when someone submit it. Please help to get post values of the form.

function widget($args, $instance) {
    extract( $args );
    // these are the widget options
    $title = apply_filters('widget_title', $instance['title']);
    echo $before_widget;
    echo '<div>';

    // Check if title is set
    if ( $title ) {
        echo $before_title . $title . $after_title;
    }
    ?>
    <form>
        <p><label for="db_sub_name">Name</label> <input type="text" name="db_sub_name" id="db_sub_name" value="" placeholder="Enter your Name"></p>
        <p><label for="db_sub_name">Email</label> <input type="text" name="db_sub_email" id="db_sub_email" value="" placeholder="Enter your Email"></p>
        <p ><input style="float:right;" type="submit" /></p>
    </form>

    <?php


    echo '</div>';
    echo $after_widget;
}

Thanks

2
  • How are you collecting the name & email? Are you just having it delivered to your email?
    – skribe
    Feb 21 '15 at 19:57
  • i just want to get post value inside plugin i know how to add them in database or email them Feb 22 '15 at 12:44
1

Your form needs to have method="post" and action="someScript.php" defined. It will send the post variables to wherever you deifine in your action=""

<form method="post" action="someScript.php" >
   <p>
     <label for="db_sub_name">Name</label>
     <input type="text" name="db_sub_name" id="db_sub_name" value="" placeholder="Enter your     Name">
   </p>
   <p>
     <label for="db_sub_name">Email</label>
     <input type="text" name="db_sub_email" id="db_sub_email" value="" placeholder="Enter your Email">
   </p>
   <p>
     <input style="float:right;" type="submit" />
   </p>
</form>
0

Can't you use a plugin for that? There is a nice mailchimp plugin available with a widget and submission form, Mailchimp For WP.

It populates your mailchimp account and that is an awesome tool for marketing emails...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.