Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [JavaScript][PHP]problem z wysyłką formularza
Forum PHP.pl > Forum > Przedszkole
grzes22
Witam, mam taki oto problem. Skopiowałem z mojego innego formularza skrypt, który sprawdza formularz i wysyła maila.
Skopiowałem na nowo stworzoną stronę i tu pojawia się problem. Skrypt wysyła maila wtedy, gdy wszystkie dane są wpisane niekoniecznie poprawni.
Natomiast nie wyświetla, że coś jest nie wpisane. Domyślam się, że to jakiś problem z JS. w pliku JS nic nie zmieniałem, na innych
formularzach działa. Z tym, że inne są na stronie index.php a ten jest na formularz.php? Czy to jest jakiś problem?
Podaję kod formularza, może ktoś mi pomoże.

  1. <?
  2. if($imie!="" && $nazwisko!="" && $telefon!="" && $email!="" && $wiadomosc!=""){
  3. error_reporting ( E_ALL ^ E_NOTICE );
  4. include('../wysylka/classes.php');
  5. include('../wysylka/htmlMimeMail.php');
  6.  
  7.  
  8. $from = "xx@xx.pl";
  9. $from1 = "xx@xx.pl";
  10.  
  11.  
  12.  
  13. $to[] = "xx.xx@xx.pl";
  14.  
  15.  
  16.  
  17.  
  18. $body_txt = "\n\n";
  19.  
  20. $subject = "[xx.pl] formularz kontaktowy";
  21.  
  22. $body_txt .= "\nImię i nazwisko: ".$imie." ".$nazwisko;
  23. $body_txt .= "\nTelefon: ".$telefon;
  24. $body_txt .= "\nEmail: ".$email;
  25. $body_txt .= "\nTreść zapytania:";
  26. $body_txt .= "\n".$wiadomosc;
  27. $body_txt .= "\n\nstrona:".$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];
  28.  
  29. $return_path = $email;
  30.  
  31.  
  32. $body_html = str_replace("\n", "<br>", $body_txt);
  33.  
  34. wysylka_maila($subject, $from, $from1, $to, $dw, $body_html, $body_txt, $att, $att_name, $mimetype, $return_path);
  35.  
  36. //koniec wysłanie maila
  37.  
  38. $komentarz_wysylka = "Twoje zapytanie zostało wysłane, dziękujemy.";
  39.  
  40. }
  41.  
  42. //print_r($_SERVER);
  43.  
  44. ?>
  45. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  46. <html xmlns="http://www.w3.org/1999/xhtml">
  47. <head>
  48. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  49.  
  50. <link rel="stylesheet" type="text/css" href="styles.css" />
  51. </head>
  52. <body>
  53. <script type="text/javascript">
  54. var url = String(document.location);
  55.  
  56. if(url.match(/index\.html\?true/) != null) {
  57. alert('Wysłano wiadomość.');
  58. } else if(url.match(/index\.html\?false/) != null){
  59. alert('Nie udało się wysłać wiadomości.');
  60. }
  61. </script>
  62. <div id="wrapper">
  63.  
  64. <div id="top" class="clear">
  65. <h1><a href="index.php">tytul</a></h1>
  66. </div>
  67.  
  68. <div id="body" class="clear">
  69. <div id="sidebar" class="column-left">
  70. <ul>
  71. <li>
  72. <h4>MENU</h4>
  73.  
  74. <ul>
  75. <?php
  76. include_once ('include/menu.php');
  77. ?>
  78. </ul>
  79.  
  80.  
  81.  
  82. <br />
  83.  
  84.  
  85.  
  86. </ul>
  87. </div>
  88. <div id="content" class="column-right">
  89. <h2></h2>
  90.  
  91. <form method="post" action="" onsubmit="return validate(this);">
  92. <table>
  93. <tr>
  94. <td width="35%">Imię: </td>
  95. <td><input type="text" name="imie" id="imie" /><br />
  96. <span class="error" id="ie">Musisz podać swoje imię!</span></td>
  97. </tr>
  98.  
  99. <tr>
  100. <td>Nazwisko: </td>
  101. <td><input type="text" name="nazwisko" id="nazwisko" /><br />
  102. <span class="error" id="ne">Musisz podać swoje nazwisko!</span></td>
  103. </tr>
  104.  
  105. <tr>
  106. <td>Telefon: </td>
  107. <td><input type="text" name="telefon" onkeydown="return onlyNumbers(event)" id="telefon" maxlength="9" /><br />
  108. <span class="error" id="te">Musisz podać nr telefonu! (9-cyfr)</span></td>
  109. </tr>
  110.  
  111. <tr>
  112. <td>E-mail: </td>
  113. <td><input type="text" name="email" id="email" /><br />
  114. <span class="error" id="ee">Musisz podać adres mailowy!</span></td>
  115. </tr>
  116.  
  117. <tr>
  118. <td style="vertical-align: top;">Wiadomość: </td>
  119. <td><textarea name="wiadomosc" id="wiadomosc" rows="10" cols="10"></textarea><br />
  120. <span class="error" id="we">Musisz podać treść wiadomości! (min. 30 znaków)</span></td>
  121. </tr>
  122.  
  123. <tr><td>&nbsp;</td><td><input type="image" src="images/send.png" /></td></tr>
  124.  
  125. </table>
  126.  
  127. <div class="inline"><input type="checkbox" id="zgoda" name="zgoda" /></div>
  128. <div class="inline2">Wyrażam zgodę na przetwarzanie Moich danych osobowych na zasadach określonych w regulaminie. Pełna treść <a href="#">REGULAMINU</a><br />
  129. <span class="error" id="ze">Musisz wyrazić zgodę!</span></div>
  130.  
  131. </form>
  132.  
  133. <br /><br />
  134. </div>
  135. </div>
  136.  
  137. <div id="footer" class="clear">
  138. <div class="footer-box">
  139. </div>
  140.  
  141. <div class="footer-box">
  142. <h4>Polecamy:</h4>
  143. <ul>
  144. <?php
  145. include_once ('include/polecamy.php');
  146. ?>
  147. </ul>
  148. </div>
  149.  
  150. <div class="footer-box">
  151. <h4>Podstrony</h4>
  152. <ul>
  153. <?php
  154. include_once ('include/menu_dol.php');
  155. ?>
  156. </ul>
  157. </div>
  158.  
  159.  
  160. </div>
  161.  
  162. <div id="footer-links">
  163. <p>
  164. &copy; 2012 Design by <a href="http://www.spyka.net">Free CSS Templates</a>
  165. </p>
  166. </div>
  167. </div>
  168. <?
  169. if($komentarz_wysylka!=""){
  170. ?>
  171. <script language="JavaScript">
  172. <!--
  173. alert("<?echo $komentarz_wysylka;?>");
  174. window.location='http://<?echo $_SERVER['SERVER_NAME'].str_replace("index.php", "", $_SERVER['SCRIPT_NAME']);?>';
  175. //-->
  176. </script>
  177. <?
  178. }
  179. ?>
  180. </body>
  181. </html>
  182.  
CuteOne
Podstawy...

Gdzie masz zdefiniowane zmienne
  1. if($imie!="" && $nazwisko!="" && $telefon!="" && $email!="" && $wiadomosc!="")

?
grzes22
tylko o to chodzi, że ja w tym skrypcie też nic nie zmienialem.
skopiowałem go z innego formularza, i formularz też skopiowałem.
Nigdzie nic nie zmieniłem, na jednym działa na 2 nie. dziwne
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.