Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. $('#send').click(function(e){
  2. e.preventDefault();
  3. $.ajax({
  4. type: 'post',
  5. url: 'index.php',
  6. data: $('form').serialize(),
  7. success: function () {
  8. $('#contactForm').fadeOut(600);
  9. $('#contactClick').hide().html('Thanks for the message! I'll get back to you shortly.').fadeIn(600);
  10. $('section#contact').height(windowHeight);
  11. $('html, body').animate({scrollTop:($('#contact').position().top)}, 'slow');
  12. }
  13. });
  14. });
  15.  
  16. <form id="myForm" action="index.php" method="post">
  17.  
  18. <label class="col-xs-2">Name:</label>
  19. <input class="col-xs-12" id="name" type="text" name="name" autocomplete="off" />
  20.  
  21. <label class="col-xs-2">Email:</label>
  22. <input class="col-xs-12" type="text" name="email" autocomplete="off" />
  23.  
  24. <label class="col-xs-2">Message:</label>
  25. <textarea class="col-xs-12" id="message" rows="10" cols="10" autocomplete="off" name="message"></textarea>
  26.  
  27. <input id="send" class="submit" type="submit" name="formSubmit" value="Send" />
  28.  
  29. </form>
  30.  
  31. <?php
  32. if($_POST['formSubmit']=="Send") {
  33.  
  34. $to = "myemail@ddress.com";
  35. $subject = "A message from your website";
  36.  
  37. $text = " Name: ";
  38. $text .= $_POST['name'];
  39. $text .= "rn";
  40. $text .= " E-mail: ";
  41. $text .= $_POST['email'];
  42. $text .= "rn";
  43. $text .= " Message: ";
  44. $text .= $_POST['message'];
  45. $text .= "rn";
  46. $wrapped_text = wordwrap($text, 120, "rn");
  47. $message = htmlentities($wrapped_text);
  48.  
  49. mail($to,$subject,$message);
  50. }
  51. ?>
  52.  
  53. <input id="send" class="submit" type="button" name="formSubmit" value="Send" />
  54.  
  55. <form id="myForm">
  56.  
  57. data: $('#myForm').serialize(),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement