Advertisement
Guest User

Untitled

a guest
Sep 13th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. 1.php
  2.  
  3. <form>
  4. <input type="text" class="req" id="ap-form-name" value="имя...">
  5.  
  6. <input type="text" class="req" id="ap-form-email" value="email...">
  7.  
  8. <textarea class="req" id="ap-form-message">сообщение...</textarea>
  9.  
  10. <button type="submit">Отправить</button>
  11. </p>
  12. </fieldset>
  13.  
  14. <fieldset class="ap-thanks">
  15. <h1>Спасибо за ваше обращение!</h1>
  16. <p>Мы обязательно обязательно ответим на него.</p> </fieldset>
  17. </form>
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. <script>
  26. jQuery('#ap').data('config',
  27. {
  28. "email_form":"info@gmail.com",
  29. })
  30. </script>
  31.  
  32. load.js
  33. function contact_form() {
  34.  
  35. ...
  36.  
  37. var _email=book.config['email_form'];
  38. var dataString = 'name='+ name + '&email=' + email + '&message=' + message+'&_email='+_email;
  39.  
  40. $.ajax({
  41. type: "POST",
  42. url: "php/submit-form-ajax.php",
  43. data: dataString,
  44. success: function(msg) {
  45.  
  46. // Check to see if the mail was successfully sent
  47. if (msg == 'Mail sent') {
  48. $("#ap-contact fieldset").hide();
  49. $("#ap-contact fieldset.ap-thanks").show();
  50.  
  51. setTimeout(function() {
  52. close_overlay();
  53. }, 5000);
  54.  
  55. } else {
  56. $('#ap-contact button').fadeIn('fast');
  57. alert('The problem with sending it, please try again!');
  58. }
  59. },
  60.  
  61. error: function(ob,errStr) {
  62. alert('Problem with sending.');
  63. }
  64. });
  65. return false;
  66. });
  67.  
  68. submit-form-ajax.php
  69.  
  70. $name = $_POST["name"];
  71. $email = $_POST["email"];
  72. $message = $_POST["message"];
  73.  
  74. $msg = "
  75. Имя: $name
  76. Email: $email
  77. Текст сообщения: $message
  78. ";
  79. $to = "info@gmail.com";
  80. $subject = "Сообщение";
  81. $message = $msg;
  82. mail($to,$subject,$message,$headers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement