Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Formularz kontaktowy
Forum PHP.pl > Forum > Gotowe rozwiązania
gilbertos
Witam,

Formularz nie wysyła mi wiadomości ze strony na e-mail. Proszę o pomoc w rozwiązaniu problemu. Próbowałem coś zmajstrować ,ale bez udanego rezultatu. Poniżej kod:

  1.  
  2. <?php
  3. if($_POST['submit'])
  4. {
  5. if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['subject']))
  6. {
  7. $error = true;
  8. }
  9. else
  10. {
  11. $to = "lukaszkoteluk@gmail.com";
  12.  
  13. $name = trim($_POST['name']);
  14. $email = trim($_POST['email']);
  15. $subject = trim($_POST['subject']);
  16. // $information = trim($_POST['information']);
  17. $message = trim($_POST['message']);
  18.  
  19. $temat = "Formularz kontaktowy";
  20.  
  21. $messages = "Imię i nazwisko: $name \r\n E-mail: $email \r\n Temat: $subject \r\n Wiadomość: $message";
  22. $headers = "Wiadomość od: . $name";
  23. $mailsent = mail($to, $temat, $messages, $headers);
  24.  
  25. if($mailsent)
  26. {
  27. $sent = true;
  28. }
  29. }
  30. }
  31.  
  32. ?>
  33. <!DOCTYPE html>
  34. <html lang="pl">
  35. <head>
  36. <meta charset="utf-8" />
  37. <title>CompandCare</title>
  38. <link rel="stylesheet" href="main.css" type="text/css">
  39. <link rel="stylesheet" href="grid.css" type="text/css" media="all">
  40. </head>
  41.  
  42. <body id="index" class="home">
  43.  
  44. <header id="banner" class="body">
  45. <img src="images/logo.png" alt="CompandCare"/>
  46.  
  47. <nav>
  48. <ul>
  49. <li><a href="index.html">home</a></li>
  50. <li><a href="usługi.html">usługi</a></li>
  51. <li class="active"><a href="kontakt1.php">kontakt</a></li>
  52. </ul>
  53. </nav>
  54.  
  55. </header><!-- banner -->
  56.  
  57. <footer id="contentinfo" class="body">
  58. <address id="about" class="vcard author">
  59. <div class="bottom">
  60. <div class="container">
  61. <div class="clearfix">
  62. <div class="grid3 first">
  63. <h3>Kontakt</h3>
  64. <div class="wrapper">
  65. <dl class="address">
  66. <dd><span>Telefon kom.:</span>600090437</dd>
  67. <dd><span>E-mail:</span><a href="lukaszkoteluk@gmail.com">lukaszkoteluk@gmail.com</a></dd>
  68. </dl>
  69. </div>
  70. </div>
  71. <div class="grid6">
  72. <h3>Formularz kontaktowy</h3>
  73. <?php if($error == TRUE) { ?>
  74. <p class="error">Nie wypełniłeś wszystkich pól w formularzu. Wypełnij pozostałe pola.</p>
  75. <?php } if ($sent == TRUE) { ?>
  76. <p class="sent">Dziękujemy. Twój e-mail został wysłany prawidłowo. Odpowiemy na niego w przeciągu 24 godzin.</p>
  77. <?php } ?>
  78. <form name="contact" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="contacts-form">
  79. <fieldset>
  80. <div class="grid3 first">
  81. <label for="name">Imię i nazwisko:<br />
  82. <input type="text" name="name" />
  83. </label>
  84. <label for="email">E-mail:<br />
  85. <input type="email" name="email" />
  86. </label>
  87. <label for="subject">Temat:<br />
  88. <input type="text" name="subject" />
  89. </label>
  90. <label for="information">Skąd o nas wiesz:<br />
  91. <select>
  92. <option value="z sieci Web">Z sieci Web</option>
  93. <option value="ulotki/ogłoszenia">ulotki/ogłoszenia</option>
  94. <option value="od znajomego">od znajomego</option>
  95. </select>
  96. </label>
  97. </div>
  98. <div class="grid3">Wiadomość:<br />
  99. <textarea name="message"></textarea>
  100. <input type="submit" name="submit" class="submit" value="Wyślij" />
  101.  
  102. <div class="alignright">
  103. <!-- <a href="" class="alt" onClick="document.getElementById('contacts-form').reset();">Wyczyść</a> &nbsp; &nbsp;<a href="#" class="alt" onClick="document.getElementById('contacts-form').submit(); ">Wyślij</a>
  104. <!-- <noscript>
  105. <input type="submit" value="Wyślij" style="border: none; background-color: transparent; text-decoration: underline;
  106. </noscript> -->
  107. </div>
  108. </div>
  109. </fieldset>
  110. </form>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <!--<span class="bio"></span>-->
  116. </address>
  117. <p>Copyright ˆ 2012 Comp&Care<br>All Rights Reserverd.</p>
  118. </footer><!-- /#contentinfo -->
  119. </body>
  120. </html>
  121.  
markonix
mail zwraca true?
gilbertos
Nie otrzymuję maila na skrzynkę. Jak mogę inaczej sprawdzić czy funkcja mail zwraca true?
markonix
  1. var_dump(mail($to, $temat, $messages, $headers));
gilbertos
zwraca bool(false)
markonix
Spróbuj wysłać po prostu maila bez formularza i nagłówków.
  1. var_dump(mail('lukaszkoteluk@gmail.com', 'Temat testowy', 'Treść testu'));
gilbertos
w dalszym ciągu ten sam błąd. Może to być wina serwera, na którym mam postawioną tę stronkę? (yoyo.pl)
markonix
Tak trudno sprawdzić w Google:
Cytat
yoyo mail

pełno wyników i opinii.
gilbertos
Dzięki już sobie poradziłem. Po prostu na yoyo.pl funkcja mail() jest wyłączona i dlatego formularz nie wysyłał wiadomości.smile.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.