Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Problem z polami wymaganymi w formularzu.
adiscan
post
Post #1





Grupa: Zarejestrowani
Postów: 64
Pomógł: 0
Dołączył: 12.04.2007

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


Mam problem z polami wymaganymi! Tzn nie wiem jak zrobić żeby komunikat o nie wypełnionym polu na tej samej stronie i bez potrzeby wypełniania ponownie formularza.


Poniższy skrypt to robi ale ... widnieje cały czas napis o nie wypełnionym polu i jesli dam wyslij i nie wypełnie pola wymaganego to czyści mi cały formularz ... i nie umie sobie z tym poradzic

I nastepna sprawa to formatowanie tresci samej wiadomosci tzn zmiennej $message tak by były zachowane wszystkie znaki w sensie zeby ENTER był Enterem a nie tak jak jest teraz JEDEN WIELKI CIĄG znakow!

Bede wdzieczny za wszystkie rady.

Wszystko znajduje sie w jednym pliku test2.php tzn formularz w htmlu i mail() w php ...

Do pola wymaganego zastosowałem instr warunkową if ... else

Oj przepraszam za tak rozwalonego posta sad.gif

  1. <?php
  2. if($name=='')
  3. {
  4. echo $error;
  5. }
  6. else
  7. {
  8. wykonaj skrypt
  9. }
  10. ?>


  1. <html>
  2.  
  3. <head>
  4. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
  5. <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
  6. <meta name="ProgId" content="FrontPage.Editor.Document">
  7. <title>Formularz Kontaktowy</title>
  8. </head>
  9.  
  10. <body>
  11.  
  12. <p align="center">
  13. <div align="right">
  14. <form action="http://www.tienspolska.com/ftp/test2.php" name="form" method="post">
  15.  <center>
  16. <table border="0" cellpadding="0" cellspacing="1" width="322" height="533" bgcolor="#EDFCE0" style="border: 0 double #008000">
  17. <tr>
  18. <td width="627" height="30" colspan="4" bordercolor="#00FFFF" bgcolor="#BCE184">
  19. <p align="center"><font color="#FFFFFF"><b>Formularz Kontaktowy</b></font> </td>
  20. </tr>
  21. <tr>
  22. <td width="193" height="40" style="border-right-style: double" bordercolor="#BCE184" bordercolorlight="#EDFCE0" bordercolordark="#BCE184"><font size="2" face="Arial">Imię i 
  23. Nazwisko:     </font> </td>
  24. <td width="759" colspan="3" height="40"> <input type="text" name="name" size="55"></td>
  25. </tr>
  26. <tr>
  27. <td width="193" height="25" style="border-right-style: double" bordercolor="#BCE184" bordercolorlight="#EDFCE0" bordercolordark="#BCE184"><font size="2" face="Arial">Ulica:</font></td>
  28. <td width="418" colspan="3" height="25"> <input type="text" name="ulica" size="55"></td>
  29. </tr>
  30. <tr>
  31. <td width="193" height="40" style="border-right-style: double" bordercolor="#BCE184" bordercolorlight="#EDFCE0" bordercolordark="#BCE184"><font size="2" face="Arial">Nr domu:</font></td>
  32. <td width="137" height="40"> <input type="text" name="numer" size="10"></td>
  33. <td width="198" height="40">
  34. <p align="center"><font face="Arial" size="2">Kod pocztowy:</font></td>
  35. </center>
  36. <td width="424" height="40">
  37. <p align="left"><input type="text" name="kod" size="14"></td>
  38. </tr>
  39. <center>
  40. <tr>
  41. <td width="193" height="26" style="border-right-style: double" bordercolor="#BCE184" bordercolorlight="#EDFCE0" bordercolordark="#BCE184"><font size="2" face="Arial">Miejscowość: </font> </td>
  42. <td width="759" colspan="3" height="26"> <input type="text" name="miejscowosc" size="55"></td>
  43. </tr>
  44. <tr>
  45. <td width="193" height="25" style="border-right-style: double" bordercolor="#BCE184" bordercolorlight="#EDFCE0" bordercolordark="#BCE184"><font size="2" face="Arial">Twoj Email:</font></td>
  46. <td width="759" colspan="3" height="25"> <input type="text" name="email" size="55"></td>
  47. </tr>
  48. <tr>
  49. <td width="193" height="40" style="border-right-style: double" bordercolor="#BCE184" bordercolorlight="#EDFCE0" bordercolordark="#BCE184"><font size="2" face="Arial">Jak mamy Ci
  50. odpowiedzieć?</font></td>
  51. <td width="759" colspan="3" height="40"> <select size="1" name="select">
  52. <option selected>E-mail zwrotny</option>
  53. <option>Telefonicznie                  
  54. </option>
  55. </select>   <font size="2" face="Arial">  nr tel.  </font><font size="1"> 
  56. </font><input type="text" name="tel" size="12"></td>
  57. </tr>
  58. <tr>
  59. <td width="193" height="40" style="border-right-style: double" bordercolor="#BCE184" bordercolorlight="#EDFCE0" bordercolordark="#BCE184"><font size="2" face="Arial">Temat
  60. wiadomoćci:             </font>
  61. </td>
  62. <td width="759" colspan="3" height="40"> <select size="1" name="subject">
  63. <option selected>Pytanie odnośnie produktów firmy Tiens</option>
  64. <option>Karta Klienta Firmy Tiens - informacje</option>
  65. <option>Zamówienie</option>
  66. <option>Reklamacje</option>
  67. <option>Inny</option>
  68.  
  69. </select></td>
  70. </tr>
  71. <tr>
  72. <td width="193" height="271" style="border-right-style: double" bordercolor="#BCE184" bordercolorlight="#EDFCE0" bordercolordark="#BCE184"><font size="2" face="Arial">Treść
  73. wiadomoćci:</font></td>
  74. <td width="759" colspan="3" height="271" style="border-top-style: double" bordercolor="#BCE184"><textarea rows="13" name="tresc" cols="50"></textarea></td>
  75. </tr>
  76. <tr>
  77. <td width="902" height="27" colspan="4" align="center" bgcolor="#BCE184">
  78. <input type="submit" value=" Wyślij  " style="border-style: double; border-color: #008000"></td>
  79. <input type="reset" value="reset">
  80. </tr>
  81. </table>
  82. </center>
  83. </div>
  84. <p align="left"> 
  85. <p align="left"> 
  86. <p align="left"><br>
  87. </p>
  88. </form>
  89.  
  90. </body>
  91.  
  92. </html>
  93.  
  94. <?php
  95. header("Content-type: text/html; charset=utf-8");
  96.  
  97.  
  98.  
  99. $name = $_POST['name'];
  100. $ulica = $_POST['ulica'];
  101. $numer = $_POST['numer'];
  102. $kod = $_POST['kod'];
  103. $miejscowosc = $_POST['miejscowosc'];
  104. $email = $_POST['email'];  //email tego kto ma pytanie
  105. $select = $_POST['select'];
  106. $tel = $_POST['tel'];
  107. $tresc = $_POST['tresc'];
  108. $error = "nie wszystkie pola są wypełnione";
  109.  
  110. /////////////////////////////////////////////////////////////
  111.  
  112.  
  113.  
  114.  
  115. if($name=='')
  116. {
  117.  
  118. echo $error;
  119.  
  120. }
  121. else
  122.  
  123. {
  124. //adresaci
  125. $do = " wiadomo ".",";
  126. $do .= " wiadomo ";
  127.  
  128. // temat maila
  129. $subject = $_POST['subject'];
  130.  
  131. // wiadomosc
  132.  
  133. $wiadomosc .= '
  134. <html>
  135. <head>
  136. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  137. <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
  138. <meta name="ProgId" content="FrontPage.Editor.Document">
  139. <title>Tytuł tej wiadomosci:</title>
  140. </head>
  141.  
  142. <body>
  143.  
  144.  
  145. <div align="left">
  146. <table border="0" cellpadding="0" cellspacing="1" width="528" height="158">
  147. <tr>
  148. <td width="155" height="20" align="left"><b>Imie i Nazwisko:</b></td>
  149. <td width="363" height="20" align="left">'.$name.'</td>
  150. </tr>
  151. <tr>
  152. <td width="155" height="21" align="left"><b>Adres:</b></td>
  153. <td align="left" width="359">'.$ulica.' '.$numer.'</td>
  154. </tr>
  155. <tr>
  156. <td width="155" height="21" align="left"></td>
  157. <td align="left" width="359">'.$kod.' '.$miejscowosc.'</td>
  158. </tr>
  159. <tr>
  160. <td width="155" height="19" align="left"><b>Kotnakt:</b></td>
  161. <td width="359" height="19" align="left">e-mail:  '.$email.'</td>
  162. </tr>
  163. <tr>
  164. <td width="155" height="21" align="left"></td>
  165. <td width="363" height="21" align="left">tel: '.$tel.'</td>
  166. </tr>
  167. <tr>
  168. <td width="155" height="21" align="left"><b>Forma odpowiedzi:</b></td>
  169. <td width="363" height="21" align="left">'.$select.'</td>
  170. </tr>
  171. <tr>
  172. <td width="155" height="21" align="left"><b><font color="#000080">Temat:</font></b></td>
  173. <td width="363" height="21" align="left"><font color="#000080"><b>'.$subject.'</b></font></td>
  174. </tr>
  175. <tr>
  176. <td width="522" height="21" colspan="2" align="left">
  177. <p align="left">--------------------------------------------------------------</td>
  178. </tr>
  179. <tr>
  180. <td width="522" height="21" colspan="2" align="left"><i>'.$tresc.'</i></td>
  181. </tr>
  182. </table>
  183. </div>
  184.  
  185. </body>
  186. </html>
  187.  
  188. ';
  189.  
  190.  
  191. //naglowki:
  192.  
  193. $naglowki = "MIME-Version: 1.0rn";
  194. $naglowki .= "Content-type: text/html; charset=utf-8rn";
  195.  
  196.  
  197. //dodatkowy naglowek
  198.  
  199. $naglowki .= "From: tienspolska.com <adiscann@wp.pl>rn";
  200. //$naglowki .= "Cc: wiadomo rn";
  201. //$naglowki .= "Bcc: wiadomo rn";
  202.  
  203.  
  204. mail ($do,$subject,$wiadomosc,$naglowki);
  205.  
  206. //print_r($_POST);
  207.  
  208. };
  209.  
  210. ?>


Ten post edytował adiscan 16.04.2007, 18:59:41
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 Aktualny czas: 22.08.2025 - 05:21