I am utilizing a WordPress sidebar widget for email capture for my e-newsletter. The wordpress plugin continues to be written to redirect to some 'success page' after submission, which is not great because I'd rather it simply output successful message inside a div underneath the form after submission therefore the customer stays around the page. How do i do this? I believed of something similar to a meta refresh around the success page to the page the customer was on, but that is pretty cumbersome when I am confident I have seen on-page email capture forms in which the success message is simply output in to the page somewhere with no redirect.

If you do not mind, I am likely to copy a great deal from the plugin's code because I am not quite sure what must be tweaked here to obtain the type of onsubmit I am searching for. Or maybe there's every other way you can let me know to get this done, I'd really thank you for assist with this. Thanks.

<?php 
function wp_email_capture_form($error = 0) {
    $url = get_option('home');
    $url = addLastCharacter($url);
?>
<div id="wp_email_capture"><form name="wp_email_capture" method="post" action="<?php echo $url; ?>">
<?php
    if (isset($_GET["wp_email_capture_error"])) {
        $error = sanitize($_GET["wp_email_capture_error"]);
        echo "<div style='width:80%;background-color: #FFCCCC; margin: 5px;font-weight'>Error: ". $error ."</div>";
    }
?>
<label class="wp-email-capture-name">Name:</label> <input name="wp-email-capture-name" type="text" class="wp-email-capture-name"><br/>
<label class="wp-email-capture-email">Email:</label> <input name="wp-email-capture-email" type="text" class="wp-email-capture-email"><br/>
<input type="hidden" name="wp_capture_action" value="1">
<input name="Submit" type="submit" value="Submit" class="wp-email-capture-submit">
</form>
</div>
<?php
    if (get_option("wp_email_capture_link") == 1) {
        echo "<p style='font-size:10px;'>Powered by <a      href='http://www.gospelrhys.co.uk/plugins/wordpress-plugins/wordpress-email-capture-plugin' target='_blank'>WP Email Capture</a></p>\n";
    }
}

function wp_email_capture_form_page($error = 0) {
    $url = get_option('home');
    $url = addLastCharacter($url);
    $display .= "<div id='wp_email_capture_2'><form name='wp_email_capture_display'     method='post' action='" . $url ."'>\n";
    if (isset($_GET["wp_email_capture_error"])) {
        $error = sanitize($_GET["wp_email_capture_error"]);
        $display .= "<div style='width:80%;background-color: #FFCCCC; margin:      5px;font-weight'>Error: ". $error ."</div>\n";
    } 
    $display .= "<label class='wp-email-capture-name'>Name:</label> <input name='wp-email-capture-name' type='text' class='wp-email-capture-name'><br/>\n";
    $display .= "<label class='wp-email-capture-email'>Email:</label> <input name='wp-email-capture-email' type='text' class='wp-email-capture-email'><br/>\n";
    $display .= "<input type='hidden' name='wp_capture_action' value='1'>\n";
    $display .= "<input name='Submit' type='submit' value='Submit' class='wp-email-capture-submit'></form></div>\n";
    if (get_option("wp_email_capture_link") == 1) {
        $display .= "<p style='font-size:10px;'>Powered by <a href='http://www.gospelrhys.co.uk/plugins/wordpress-plugins/wordpress-email-capture-plugin' target='_blank'>WP Email Capture</a></p>\n";
    } 

    return $display;
}

function wp_email_capture_display_form_in_post($content) {
    $get_form = wp_email_capture_form_page();
    $content = str_replace("[wp_email_capture_form]", $get_form, $content);
    return $content;
}
?>

Here's my first attempt for a Stack Overflow answer:

Your form action presently directs to another page, but you really need it to guide to the page you are already on. This can be done having a blank action attribute, like so:

<form action="">

Once you have carried this out, you should use the $_POST data on that same page. Within the page div in which you want the output, try something similar to this:

if($_POST['wp_capture_action'] == 1)
{
    // The form has been submitted, so
    // print the success/failure message here
}
else
{
    // The form hasn't been submitted, so print
    // the form here.
}

I really hope this can help!