Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> problem z formularzem kontaktowym
sasadam
post
Post #1





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 15.04.2014

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


witam, mam mały problem z formularzem kontaktowym na mojej stronie, mianowicie plik o nazwie "contact-form.php" umieszczony w folderze "php" wygląda następująco:

  1. <?php
  2. header('Expires: ' . gmdate('r', 0));
  3.  
  4. header('Content-type: application/json');
  5.  
  6. require 'php-mailer/class.phpmailer.php';
  7.  
  8. // Your email address
  9. $to = 'kontakt@umiem-pomagam.pl';
  10.  
  11. $subject = $_POST['subject'];
  12.  
  13. if($to) {
  14.  
  15. $name = $_POST['name'];
  16. $email = $_POST['email'];
  17.  
  18. $fields = array(
  19. 0 => array(
  20. 'text' => 'Name',
  21. 'val' => $_POST['name']
  22. ),
  23. 1 => array(
  24. 'text' => 'Email address',
  25. 'val' => $_POST['email']
  26. ),
  27. 2 => array(
  28. 'text' => 'Message',
  29. 'val' => $_POST['message']
  30. )
  31. );
  32.  
  33. $message = "";
  34.  
  35. foreach($fields as $field) {
  36. $message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . "<br>\n";
  37. }
  38.  
  39. $mail = new PHPMailer;
  40.  
  41. $mail->IsSMTP(); // Set mailer to use SMTP
  42.  
  43. // Optional Settings
  44. //$mail->Host = 'mail.yourserver.com'; // Specify main and backup server
  45. //$mail->SMTPAuth = true; // Enable SMTP authentication
  46. //$mail->Username = 'username'; // SMTP username
  47. //$mail->Password = 'secret'; // SMTP password
  48. //$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
  49.  
  50. $mail->From = $email;
  51. $mail->FromName = $_POST['name'];
  52. $mail->AddAddress($to); // Add a recipient
  53. $mail->AddReplyTo($email, $name);
  54.  
  55. $mail->IsHTML(true); // Set email format to HTML
  56.  
  57. $mail->CharSet = 'UTF-8';
  58.  
  59. $mail->Subject = $subject;
  60. $mail->Body = $message;
  61.  
  62. if(!$mail->Send()) {
  63. $arrResult = array ('response'=>'error');
  64. }
  65.  
  66. $arrResult = array ('response'=>'success');
  67.  
  68. echo json_encode($arrResult);
  69.  
  70. } else {
  71.  
  72. $arrResult = array ('response'=>'error');
  73. echo json_encode($arrResult);
  74.  
  75. }
  76. ?>



natomiast kod na stronie html w dzile kontakt wygląda tak:

  1. <!--Contact form-->
  2. <div class="col-lg-12 col-sm-12 col-md-12 col-xs-12 no-pad wow fadeInLeft" data-wow-delay="0.5s" data-wow-offset="100">
  3.  
  4. <form class="contact2-page-form col-lg-8 col-sm-12 col-md-8 col-xs-12 no-pad contact-v2" id="contactForm">
  5.  
  6.  
  7. <div class="form-title-text no-pad">Skontaktuj się z nami za pośrednictwem formularza</div>
  8.  
  9.  
  10. <div class="alert alert-success hidden col-lg-12 col-sm-12 col-md-12 col-xs-12" id="contactSuccess">
  11. <strong>Sukces!</strong> Wiadomość została wysłana.
  12. </div>
  13.  
  14. <div class="alert alert-error hidden col-lg-12 col-sm-12 col-md-12 col-xs-12" id="contactError">
  15. <strong>Błąd!</strong> Wystąpił niespodziewany błąd. Prosimy skontaktoqwać się w sposób tradycyjny..
  16. </div>
  17.  
  18. <div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">
  19. <input type="text" class="contact2-textbox" placeholder="Imie i nazwisko*" name="name" id="name" />
  20. </div>
  21.  
  22. <div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">
  23. <input type="email" class="contact2-textbox" placeholder="Email*" name="email" id="email"/>
  24. </div>
  25.  
  26. <div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">
  27. <input type="text" placeholder="Tytuł*" class="contact2-textbox" name="subject" id="subject">
  28. </div>
  29.  
  30.  
  31.  
  32. <div class="col-lg-12 col-sm-12 col-md-12 col-xs-12">
  33. <textarea class="contact2-textarea" placeholder="Tresc zapytania..." name="message" id="message"></textarea>
  34. </div>
  35.  
  36. <div class="col-lg-12 col-sm-12 col-md-12 col-xs-12">
  37. <section class="color-7" id="btn-click">
  38. <button class="icon-mail btn2-st2 btn-7 btn-7b" data-loading-text="Loading..." type="submit">Wyslij</button>
  39.  
  40. </section>
  41. </div>
  42.  
  43.  
  44. </form>



Mój problem polega na tym, że po wpisaniu treści w formularzu na stronie www... pojazwia się tylko komunikat, że wiadomość została wysłana, jednak nic nie dochodzi na skrzynkę... w kodzie html widzę, że nie ma żadnego odwołania do pliku php odpowiedzialnego za proawidłową wysyłke na wskazany adres... możecie mi powiedziec jak dokładnie i gdzie w kodzie html mam dopisać połaćzenie do skryptu php? bo chyba w tym jest problem.

z góry dziękuje za każdą pomoc, pozdrawiam serdecznie, Adam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
sasadam
post
Post #2





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 15.04.2014

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


witam jedyny plij js jaki pasuje do tego problemu i który mam w folderze js nosi nazwe "view.contact" i wygląda następująco...

  1. /*
  2. Name: View - Contact
  3. Written by: Crivos - (http://www.crivos.com)
  4. Version: 1.0
  5. */
  6.  
  7. var Contact = {
  8.  
  9. initialized: false,
  10.  
  11. initialize: function() {
  12.  
  13. if (this.initialized) return;
  14. this.initialized = true;
  15.  
  16. this.build();
  17. this.events();
  18.  
  19. },
  20.  
  21. build: function() {
  22.  
  23. this.validations();
  24.  
  25. },
  26.  
  27. events: function() {
  28.  
  29.  
  30.  
  31. },
  32.  
  33. validations: function() {
  34.  
  35. $("#contactForm").validate({
  36. submitHandler: function(form) {
  37.  
  38. $.ajax({
  39. type: "POST",
  40. url: "php/contact-form.php",
  41. data: {
  42. "name": $("#contactForm #name").val(),
  43. "email": $("#contactForm #email").val(),
  44. "subject": $("#contactForm #subject").val(),
  45. "message": $("#contactForm #message").val()
  46. },
  47. dataType: "json",
  48. success: function (data) {
  49. if (data.response == "success") {
  50.  
  51. $("#contactSuccess").removeClass("hidden");
  52. $("#contactError").addClass("hidden");
  53.  
  54. $("#contactForm #name, #contactForm #email, #contactForm #subject, #contactForm #message")
  55. .val("")
  56. .blur()
  57. .closest(".control-group")
  58. .removeClass("success")
  59. .removeClass("error");
  60.  
  61. if(($("#contactSuccess").position().top - 80) < $(window).scrollTop()){
  62. $("html, body").animate({
  63. scrollTop: $("#contactSuccess").offset().top - 80
  64. }, 300);
  65. }
  66.  
  67. } else {
  68.  
  69. $("#contactError").removeClass("hidden");
  70. $("#contactSuccess").addClass("hidden");
  71.  
  72. if(($("#contactError").position().top - 80) < $(window).scrollTop()){
  73. $("html, body").animate({
  74. scrollTop: $("#contactError").offset().top - 80
  75. }, 300);
  76. }
  77.  
  78. }
  79. }
  80.  
  81. });
  82. },
  83. rules: {
  84. name: {
  85. required: true
  86. },
  87. email: {
  88. required: true,
  89. email: true
  90. },
  91. subject: {
  92. required: true
  93. },
  94. message: {
  95. required: true
  96. }
  97. },
  98. highlight: function (element) {
  99. $(element)
  100. .closest(".control-group")
  101. .removeClass("success")
  102. .addClass("error");
  103. },
  104. success: function (element) {
  105. $(element)
  106. .closest(".control-group")
  107. .removeClass("error")
  108. .addClass("success");
  109. }
  110. });
  111.  
  112. }
  113.  
  114. };
  115.  
  116. Contact.initialize();


mam nadzieje ze to jakos pomoze rozwiazac moj problem... mam okolo 20 plikow js w tym folderze ale chyba ten za to odpowiada...
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 17.10.2025 - 23:25