Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp me with a simple newsletter subscription form?
    primarykey
    data
    text
    <p>The newsletter subscription form I am working on can be found in the <strong>footer</strong> at <a href="http://landingdev.fishlist.com/" rel="nofollow">this link.</a></p> <p>Currently, when the form is submitted, the error/success message displays on a new page.</p> <p>Instead I would like for the error/success message to display directly below the form in the footer.</p> <p>IE. If a user enters the email address name@website.com, the text "Success" should display below the input field instead of on a new page.</p> <p>Help would be greatly appreciated!</p> <p>Here's what I've got now:</p> <p><strong>In the Header</strong></p> <pre><code>&lt;script&gt; function submitEmail() { var email = $('#emailText').val(); jQuery.post('/common/php/send_news.php', { email: email },function(data){ $('#submissionResponse').html(data); },html); } &lt;/script&gt; </code></pre> <p><strong>FORM</strong></p> <pre><code>&lt;form method="post"&gt; &lt;fieldset&gt; &lt;h3&gt;&lt;/h3&gt; &lt;input type="text" name="email" maxlength="80" class="input" value="enter your email address..." onfocus="this.className=('input_active')" onblur="this.className=('input')" onclick="this.value='';" /&gt; &lt;input type="button" name="submit" value="" class="subscribe_btn" onmouseover="this.className=('subscribe_btn_over')" onmouseout="this.className=('subscribe_btn')" onclick="submitEmail();" /&gt; &lt;small&gt;*we will not share your email address&lt;/small&gt;&lt;span class="clear"&gt;&lt;/span&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;div id="submissionResponse"&gt;&lt;/div&gt; </code></pre> <p><strong>send_news.php</strong></p> <pre><code>&lt;?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "test@emailtest.com"; $email_subject = "Newsletter Subscription"; function died($error) { // your error code can go here echo "There was an error with your submission"; echo $error."&lt;br /&gt;&lt;br /&gt;"; die(); } // validation expected data exists if( !isset($_POST['email'])) { died('There was an error with your submission'); } $email_from = $_POST['email']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.&lt;br /&gt;'; } if(strlen($error_message) &gt; 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Email: ".clean_string($email_from)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?&gt; &lt;!-- include your own success html here --&gt; Thanks for signup up for the Newsletter! &lt;?php } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload