Javascript/ PHP events update sign up button -


i'm trying design basic javascript email sign events update, see on under construction , coming pages. visitor add email , click submit add email list, basic ajax or jquery "thank signing up" message. need use pho email validator.

html

<form action="scripts/mail.php" method="post">   <input type="email" name="email" id="email" placeholder="enter email here....." tabindex="1">   <input type="submit" name="submit" id="submitbtn" value="signup" class="submit-btn" tabindex="2"> </form> 

with php file below:

<?php   $from = "events@spectator.co.uk";   $email = $_post['email'];   $to = "datunrase@pressholdings.com";   $subject = "please add me events mailing list";   $mailheader = "email: $email \r\n";   mail($to, $subject, $mailheader) or die("error!");   echo "<script type=\"text/javascript\">".     "alert('thanks! keep updated');".     "</script>"; ?> 

then used javascript signup.js:

$(document).ready(function(){   var mousedownhappened = false;   $("#submitbtn").mousedown(function() {     mousedownhappened = true;   });   $("#email").focus(function(){     $(this).animate({       opacity: 1.0,       width: '250px'     }, 300, function(){       // callback method empty     });     // display submit button     $("#submitbtn").fadein(300);   });   $("#submitbtn").on("click", function(e){     e.stopimmediatepropagation();     $("#signup").fadeout(230, function(){       // callback method display new text       // setup other codes here store e-mail address       $(this).after('<p id="success">thanks! keep updated.</p>');     });   });   $("#email").blur(function(){     if(mousedownhappened) {       // reset mousedown , cancel fading effect       mousedownhappened = false;     } else {       $("#email").animate({         opacity: 0.75,         width: '250px'       }, 500, function(){         // callback method empty       });       // hide submit button       $("#submitbtn").fadeout(400);     }   }); }); 

but need make function properly. first want email it's from, says nobody.

also know js , php seems override each other when comes email confirmation text. can tell me what's best use? , after sign want visitor stay on same page. thanks.

in order correctly display "from" should set in $mailheader variable. change this:

$mailheader = 'from: ' . $email . "\r\n" . 'reply-to: '. $email . "\r\n"; 

Comments