Mam formularz i pewien zwiazany z nim problem. Troszke jest jeszcze do dopracowanie ale oto jego kod:

  1. <?php
  2.  
  3.  
  4. // sprawdzamy, czy zmienna $submit jest pusta
  5. if (empty($_POST['submit'])) {
  6. ?>
  7. <html>
  8. <head>
  9. <title>Ankieta</title>
  10. <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
  11. </head>
  12. <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
  13. <table id="Table_01" width="888" height="450" border="0" cellpadding="0" cellspacing="0" align="center">
  14. <tr>
  15. <td colspan="5">
  16. <img src="images/questionnaire_01a.gif" width="888" height="119" alt=""></td>
  17. </tr>
  18. <tr>
  19. <td background="images/questionnaire_02.gif">
  20. </td>
  21. <td colspan="2" bgcolor="#ffffff" width="792"><div style="margin-left:10px; margin-right:10px;">
  22.  <p>
  23.  <?php 
  24. echo $_SESSION['blad'];
  25. $_SESSION['blad'] = "";
  26. ?>
  27. </p>
  28.  <form method="post">
  29.  <p>1.1 Gender </p>
  30.  <label>
  31.  <input type="radio" name="Plec" value="Male" />
  32. Male</label>
  33.  <br />
  34.  <label>
  35.  <input type="radio" name="Plec" value="Female" />
  36. Female</label>
  37.  <p>1.2 Age </p>
  38.  <label>
  39.  <input type="radio" name="Wiek" value="15-24" />
  40. 15-24</label>
  41.  <br />
  42.  <label>
  43.  <input type="radio" name="Wiek" value="25-34" />
  44. 25-34</label>
  45.  <br />
  46.  <label>
  47.  <input type="radio" name="Wiek" value="35-44" />
  48. 35-44</label>
  49.  <br />
  50.  <label>
  51.  <input type="radio" name="Wiek" value="45-54" />
  52. 45-54</label>
  53.  <br />
  54.  <label>
  55.  <input type="radio" name="Wiek" value="55-64" />
  56. 55-64</label>
  57. <br />
  58.  <label>
  59.  <input type="radio" name="Wiek" value="65+" />
  60. 64+</label>
  61.  
  62. <p>1.3 How long have you used the Internet?</p>
  63.  <label>
  64. <input type="radio" name="RadioGroup" value="Less than 3 Months" />
  65. Less than 3 Months</label>
  66. <br />
  67. <label>
  68. <input type="radio" name="RadioGroup" value="3 Months to 6 Months" />
  69. 3 Months to 6 Months</label>
  70. <br />
  71. <label>
  72. <input type="radio" name="RadioGroup" value="6 Months to 1 Year" />
  73. 6 Months to 1 Year</label>
  74. <br />
  75. <label>
  76. <input type="radio" name="RadioGroup" value="1 to 2 Years" />
  77. 1 to 2 Years</label>
  78. <br />
  79. <label>
  80. <input type="radio" name="RadioGroup" value="More than 2 Years" />
  81. More than 2 Years</label>
  82. <p>1.4 Where do you access the internet? (tick all answers that are true in your case)</p>
  83. <p><label><input name="checkbox1[]" type="checkbox" value="Home"/>Home </label><br />
  84. <label><input name="checkbox1[]" type="checkbox" value="Office"/>Office </label><br />
  85. <label><input name="checkbox1[]" type="checkbox" value="University"/>University </label><br />
  86. <label><input name="checkbox1[]" type="checkbox" value="Internet Café"/>Internet Café </label><br />
  87. <label><input name="checkbox1[]" type="checkbox" value="Other"/>Other</label><br />
  88. </p>
  89.  
  90. <p>1.5 For what purposes do you use the internet? (tick all answers that are true in your case)</p>
  91. <p><label><input name="checkbox2[]" type="checkbox" value="Communication"/>Communication </label><br />
  92. <label><input name="checkbox2[]" type="checkbox" value="Education"/>Education </label><br />
  93. <label><input name="checkbox2[]" type="checkbox" value="Games"/>Games </label><br />
  94. <label><input name="checkbox2[]" type="checkbox" value="Information"/>Information </label><br />
  95. <label><input name="checkbox2[]" type="checkbox" value="Internet banking"/>Internet banking</label><br />
  96. <label><input name="checkbox2[]" type="checkbox" value="Online shopping"/>Online shopping</label><br />
  97. <label><input name="checkbox2[]" type="checkbox" value="Watch TV / Listen to Music"/>Watch TV / Listen to Music</label><br />
  98. <label><input name="checkbox2[]" type="checkbox" value="Work"/>Work</label><br />
  99. <label><input name="checkbox2[]" type="checkbox" value="Other"/>Other </label><input name="checkbox2[]" /><br />
  100. <p>1.6 On what level you assume your computer skills are?</p>
  101.  <label>
  102. <input type="radio" name="RadioGroup2" value="Basic" />
  103. Basic</label>
  104. <br />
  105. <label>
  106. <input type="radio" name="RadioGroup2" value="Intermediate" />
  107. Intermediate</label>
  108. <br />
  109. <label>
  110. <input type="radio" name="RadioGroup2" value="Advanced" />
  111. Advanced</label>
  112.  
  113. <br />
  114. <p>1.7 How familiar you are with using the internet?</p>
  115.  <label>
  116. <input type="radio" name="RadioGroup3" value="Little" /> 
  117. Little
  118. </label>
  119.  <br />
  120. <label>
  121. <input type="radio" name="RadioGroup3" value="Quite" /> 
  122. Quite
  123. </label>
  124. <br />
  125. <label>
  126. <input type="radio" name="RadioGroup3" value="Very" /> 
  127. Very
  128. </label>
  129.  
  130.  
  131. </p>
  132.  
  133.  </div>
  134. </td>
  135. <td colspan="2" background="images/questionnaire_04.gif">
  136. </td>
  137. </tr>
  138. <tr>
  139. <td colspan="5">
  140. <img src="images/questionnaire_05.gif" width="888" height="40" alt=""></td>
  141. </tr>
  142. <tr>
  143. <td colspan="2" rowspan="2">
  144. <img src="images/questionnaire_06.gif" width="735" height="70" alt=""></td>
  145. <td colspan="2">
  146. <input type="image" name="submit" src="images/questionnaire_07.gif" value="Wyslij"/></form></td>
  147. <td rowspan="2">
  148. <img src="images/questionnaire_08.gif" width="33" height="70" alt=""></td>
  149. </tr>
  150. <tr>
  151. <td colspan="2">
  152. <img src="images/questionnaire_09.gif" width="120" height="27" alt=""></td>
  153. </tr>
  154. <tr>
  155. <td>
  156. <img src="images/spacer.gif" width="48" height="1" alt=""></td>
  157. <td>
  158. <img src="images/spacer.gif" width="687" height="1" alt=""></td>
  159. <td>
  160. <img src="images/spacer.gif" width="105" height="1" alt=""></td>
  161. <td>
  162. <img src="images/spacer.gif" width="15" height="1" alt=""></td>
  163. <td>
  164. <img src="images/spacer.gif" width="33" height="1" alt=""></td>
  165. </tr>
  166. </table>
  167. <!-- End ImageReady Slices -->
  168. </body>
  169. </html>
  170.  
  171. <?php
  172. } elseif (!empty($_POST['Plec']) && !empty($_POST['Wiek']) && !empty($_POST['RadioGroup'])) {
  173. // sprawdzamy, czy zmienne przesane z formularza nie s± puste
  174. // je¿eli poy tworzona jest wiadomo¶æ
  175. // zmienna $message zawiera tre¶æ wiadomosci
  176.  
  177. $message = "n1.1 {$_POST['Plec']}
  178. n1.2 {$_POST['Wiek']}
  179. n1.3 {$_POST['RadioGroup']}
  180. n1.4 ";
  181. foreach ($_POST['checkbox1'] as $val) {
  182. $message .= "n - $val ";
  183. }
  184. $message .= "n1.5 ";
  185. foreach ($_POST['checkbox2'] as $val) {
  186. $message .= "n - $val ";
  187. }
  188. $message .= "n1.6 {$_POST['RadioGroup2']}
  189. n1.7 {$_POST['RadioGroup3']}";
  190.  
  191. // zmienna $header zawiera przede wszystkim adres zwrotny
  192. $header = "From: Ankieta";
  193. // funkcja mail() za pomoc± której wiadomo¶æ zostanie wys³ana
  194. @mail("arti@loveless.pl","Ankieta 1/5 $_SERVER[ 'REMOTE_ADDR' ] ","$message","$header")
  195. or die('Nie uda³o siê wys³aæ wiadomo¶ci');
  196.  
  197.  
  198. if ($_POST['RadioGroup'] == '3 Months to 6 Months') { 
  199. header('Location: questionnaire2.php'); 
  200. } else { 
  201. header('Location: questionnaire2.php');
  202. }
  203.  
  204.  
  205.  
  206. // wywietlenie komunikatu w przypadku powodzenia 
  207.  
  208.  
  209. } else { 
  210. $_SESSION['blad'] = "<span style="color: #FF0000; text-align: center;">Wypelnij wszystkie pola formularza!</span>";
  211. header('Location: questionnaire1.php');
  212. }
  213.  
  214. ?>


Problem z nim jest taki, ze nie wiem jak zrobic zeby po wyswietleniu bledu zwiazanego z wypelnieniem wszystkich pol formularza dogrywal sie spowrotem formularz z wartosciami zaznaczonymi wczesniej. Czy moglby mi ktos pomoc z tym ? Jesli mozna by bylo prosic to odrazu moglby ktos napisac co gdzie i jak wstawic ?