Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z formularzem kontaktowym, Nie docierają do mnie wiadomości
senior.pol
post 3.12.2011, 22:16:44
Post #1





Grupa: Zarejestrowani
Postów: 158
Pomógł: 0
Dołączył: 10.08.2011

Ostrzeżenie: (0%)
-----


Witam
Pytanie mam proste. Co mam nie tak w tym skrypcie, że nie docierają do mnie wiadomości?
  1. jQuery(document).ready(function($) {
  2.  
  3. // hide messages
  4. $("#error").hide();
  5. $("#success").hide();
  6.  
  7. // on submit...
  8. $("#contactForm #submit").click(function() {
  9. $("#error").hide();
  10.  
  11. //required:
  12.  
  13. //name
  14. var name = $("input#name").val();
  15. if(name == ""){
  16. $("#error").fadeIn().text("Name required.");
  17. $("input#name").focus();
  18. return false;
  19. }
  20.  
  21. // email
  22. var email = $("input#email").val();
  23. if(email == ""){
  24. $("#error").fadeIn().text("Email required");
  25. $("input#email").focus();
  26. return false;
  27. }
  28.  
  29. // web
  30. var web = $("input#web").val();
  31. if(web == ""){
  32. $("#error").fadeIn().text("Web required");
  33. $("input#web").focus();
  34. return false;
  35. }
  36.  
  37. // comments
  38. var comments = $("#comments").val();
  39.  
  40. // send mail php
  41. var sendMailUrl = $("#sendMailUrl").val();
  42.  
  43. //to, from & subject
  44. var to = $("#to").val();
  45. var from = $("#from").val();
  46. var subject = $("#subject").val();
  47.  
  48. // data string
  49. var dataString = 'name='+ name
  50. + '&email=' + email
  51. + '&web=' + web
  52. + '&comments=' + comments
  53. + '&to=' + to
  54. + '&from=' + from
  55. + '&subject=' + subject;
  56. // ajax
  57. $.ajax({
  58. type:"POST",
  59. url: sendMailUrl,
  60. data: dataString,
  61. success: success()
  62. });
  63. });
  64.  
  65.  
  66. // on success...
  67. function success(){
  68. $("#success").fadeIn();
  69. $("#contactForm").fadeOut();
  70. }
  71.  
  72. return false;
  73. });

i
  1. <script type="text/javascript" src="js/form-validation.js"></script>
  2. <form id="contactForm" action="#" method="post">
  3. <div>
  4. <label>Imię i nazwisko</label>
  5. <input name="name" id="name" type="text" class="form-poshytip" title="Wpisz pełne dane" />
  6. </div>
  7. <div>
  8. <label>Email</label>
  9. <input name="email" id="email" type="text" class="form-poshytip" title="Twój adres email" />
  10. </div>
  11. <div>
  12. <label>Temat</label>
  13. <input name="web" id="web" type="text" class="form-poshytip" title="Temat wiadomości" />
  14. </div>
  15. <div>
  16. <label>Wiadomość</label>
  17. <textarea name="comments" id="comments" rows="5" cols="20" class="form-poshytip" title="Tekst wiadomości"></textarea>
  18. </div>
  19.  
  20. <!-- send mail configuration -->
  21. <input type="hidden" value="xxxx@xxxxxxxxxxx" name="to" id="to" />
  22. <input type="hidden" value="xxxx@xxxxxxxxxxx" name="from" id="from" />
  23. <input type="hidden" value="From torn wordpress online" name="subject" id="subject" />
  24. <input type="hidden" value="send-mail.php" name="sendMailUrl" id="sendMailUrl" />
  25. <!-- ENDS send mail configuration -->
  26.  
  27. <p><input type="button" value="WYŚLIJ" name="submit" id="submit" /></p>
  28. <p id="error" class="warning">Message</p>
  29. </form>
  30. <p id="success" class="success">Wiadomość wysłana !</p>

  1. <?php
  2.  
  3. //vars
  4. $subject = $_POST['subject'];
  5. $to = explode(',', $_POST['to'] );
  6.  
  7. $from = $_POST['email'];
  8.  
  9. //data
  10. $msg = "NAME: " .$_POST['name'] ."<br>\n";
  11. $msg .= "EMAIL: " .$_POST['email'] ."<br>\n";
  12. $msg .= "WEBSITE: " .$_POST['web'] ."<br>\n";
  13. $msg .= "COMMENTS: " .$_POST['comments'] ."<br>\n";
  14.  
  15. //Headers
  16. $headers = "MIME-Version: 1.0\r\n";
  17. $headers .= "Content-type: text/html; charset=UTF-8\r\n";
  18. $headers .= "From: <".$from. ">" ;
  19.  
  20.  
  21. //send for each mail
  22. foreach($to as $mail){
  23. mail($mail, $subject, $msg, $headers);
  24. }
  25.  
  26. ?>

Z góry dziękuję za odpowiedź smile.gif

Ten post edytował senior.pol 3.12.2011, 22:37:53
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 07:35