Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [HTML][MySQL][PHP]Problem z insertem danych z formy html do mysql
Forum PHP.pl > Forum > Przedszkole
jaruzelskee
Hej próbuje przesłac dane przez formularz do bazy, niestety bezskutecznie. Czy ktoś może wskazac mi błąd?
Oto kod formularza:

  1. <form id="form_492042" class="appnitro" method="post" action="wniosekforma.php">
  2. <div class="form_description">
  3.  
  4.  
  5. </div>
  6. <ul >
  7.  
  8. <li id="li_1" >
  9. <label class="description" for="element_1">Imię Nazwisko </label>
  10. <span>
  11. <input id="element_1_1" name= "Imie" class="element text" maxlength="255" size="8" value=""/>
  12. <label>Imię</label>
  13. </span>
  14. <span>
  15. <input id="element_1_2" name= "Nazwisko" class="element text" maxlength="255" size="14" value=""/>
  16. <label>Nazwisko</label>
  17. </span>
  18. </li> <li id="li_2" >
  19. <label class="description" for="element_2">Pesel </label>
  20. <div>
  21. <input id="element_2" name="pesel" class="element text medium" type="text" maxlength="255" value=""/>
  22. </div>
  23. </li> <li id="li_3" >
  24. <label class="description" for="element_3">Addres Zamieszkania </label>
  25.  
  26. <div>
  27. <input id="element_3_1" name="ulica" class="element text large" value="" type="text">
  28. <label for="element_3_1">Ulica</label>
  29. </div>
  30.  
  31.  
  32.  
  33. <div class="left">
  34. <input id="element_3_3" name="miasto" class="element text medium" value="" type="text">
  35. <label for="element_3_3">Miasto</label>
  36. </div>
  37.  
  38.  
  39.  
  40. <div class="left">
  41. <input id="element_3_5" name="kodpocztowy" class="element text medium" maxlength="15" value="" type="text">
  42. <label for="element_3_5">Kod pocztowy</label>
  43. </div>
  44.  
  45.  
  46. </li> <li id="li_4" >
  47. <label class="description" for="element_4">dataurodzenia </label>
  48. <span>
  49. <input id="element_4_1" type name="miesiacuro" class="element text" size="2" maxlength="2" value="" type="text"> /
  50. <label for="element_4_1">MM</label>
  51. </span>
  52. <span>
  53. <input id="element_4_2" name="dzienuro" class="element text" size="2" maxlength="2" value="" type="text"> /
  54. <label for="element_4_2">DD</label>
  55. </span>
  56. <span>
  57. <input id="element_4_3" name="rokuro" class="element text" size="4" maxlength="4" value="" type="text">
  58. <label for="element_4_3">YYYY</label>
  59. </span>
  60.  
  61. <span id="calendar_4">
  62. <img id="cal_img_4" class="datepicker" src="calendar.gif" alt="Pick a date.">
  63. </span>
  64. <script type="text/javascript">
  65. Calendar.setup({
  66. inputField : "element_4_3",
  67. baseField : "element_4",
  68. displayArea : "calendar_4",
  69. button : "cal_img_4",
  70. ifFormat : "%B %e, %Y",
  71. onSelect : selectDate
  72. });
  73. </script>
  74.  
  75. </li> <li id="li_5" >
  76. <label class="description" for="element_5">Miejsce urodzenia </label>
  77. <div>
  78. <input id="element_5" name="miejsceurodzenia" class="element text medium" type="text" maxlength="255" value=""/>
  79. </div>
  80. </li> <li id="li_6" >
  81. <label class="description" for="element_6">Telefon </label>
  82. <div>
  83. <input id="element_6" name="telefon" class="element text medium" type="text" maxlength="255" value=""/>
  84. </div>
  85. </li> <li id="li_7" >
  86. <label class="description" for="element_7">Email </label>
  87. <div>
  88. <input id="element_7" name="email" class="element text medium" type="text" maxlength="255" value=""/>
  89. </div>
  90. </li>
  91.  
  92.  
  93. <li id="li_77" >
  94. <label class="description" for="element_77">Stopien</label>
  95. <div>
  96. <input id="element_77" name="stopien" class="element text medium" type="text" maxlength="255" value=""/>
  97. </div>
  98. </li>
  99.  
  100.  
  101.  
  102. <li id="li_8" >
  103. <label class="description" for="element_8">rok uzyskania stopnia </label>
  104. <div>
  105. <input id="element_8" name="rokuzyskaniastopnia" class="element text medium" type="text" maxlength="255" value=""/>
  106. </div>
  107. </li>
  108. <li id="li_14" >
  109. <label class="description" for="element_14">Certyfikat odesłac na adres: </label>
  110. <span>
  111. <input id="element_14_1" name="adresodbioru" value="klubu" class="element radio" type="radio" />
  112. <label class="choice" for="element_14_1" >klubu</label>
  113. <input id="element_14_2" name="adresodbioru" class="element radio" type="radio" value="odbiórosobisty" />
  114. <label class="choice" for="element_14_2">odbiór osobisty</label>
  115. <input id="element_14_3" name="adresodbioru" class="element radio" type="radio" value="inny" />
  116. <label class="choice" for="element_14_3">inny adres:</label>
  117.  
  118. </span>
  119. </li>
  120.  
  121.  
  122.  
  123.  
  124. <li> <input id="element_123" name="innyadres" class="element text medium" type="text" maxlength="255" value=""/>
  125. </li>
  126. </li> <li id="li_10" >
  127. <label class="description" for="element_10">Czas trwania kursu </label>
  128. <div>
  129. <input id="element_10" name="czastrwaniakursu" class="element text medium" type="text" maxlength="255" value=""/>
  130. </div>
  131. </li>
  132.  
  133.  
  134.  
  135. <li id="li_11" >
  136. <label class="description" for="element_11">Miejsce kursu </label>
  137. <div>
  138. <input id="element_11" name="miejscekursu" class="element text medium" type="text" maxlength="255" value=""/>
  139. </div>
  140. </li>
  141.  
  142.  
  143. <li id="li_222" >
  144. <label class="description" for="element_222">Dowód wpłaty za certyfikat (nr faktury, paragonu, nr KP) </label>
  145. <div>
  146. <input id="element_222" name="dowodwplaty" class="element text medium" type="text" maxlength="255" value=""/>
  147. </div>
  148. </li>
  149.  
  150. <li id="li_13" >
  151. <label class="description" for="element_13">Data przelewu </label>
  152. <span>
  153. <input id="element_13_1" name="dMM" class="element text" size="2" maxlength="2" value="" type="text"> /
  154. <label for="element_13_1">MM</label>
  155. </span>
  156. <span>
  157. <input id="element_13_2" name="dDD" class="element text" size="2" maxlength="2" value="" type="text"> /
  158. <label for="element_13_2">DD</label>
  159. </span>
  160. <span>
  161. <input id="element_13_3" name="dYY" class="element text" size="4" maxlength="4" value="" type="text">
  162. <label for="element_13_3">YYYY</label>
  163. </span>
  164.  
  165. <span id="calendar_13">
  166. <img id="cal_img_13" class="datepicker" src="calendar.gif" alt="Pick a date.">
  167. </span>
  168. <script type="text/javascript">
  169. Calendar.setup({
  170. inputField : "element_13_3",
  171. baseField : "element_13",
  172. displayArea : "calendar_13",
  173. button : "cal_img_13",
  174. ifFormat : "%B %e, %Y",
  175. onSelect : selectDate
  176. });
  177. </script>
  178.  
  179. </li>
  180.  
  181.  
  182. <li id="li_15" >
  183. <label class="description" for="element_15"> </label>
  184. <span>
  185. <input id="element_15_1" name="daneosob" class="element radio" type="radio" value="true" />
  186. <label class="choice" for="element_15_1">Wyrażam zgodę na przetwarzanie danych osobowych
  187. (Dz. U. Nr 133, poz. 883)."
  188. <input id="element_15_2" name="oswiadczenie" class="element radio" type="radio" value="true" />
  189. <label class="choice" for="element_15_2">Oświadczam, że ukończyłem część teoretyczną i praktyczną szkolenia. </label>
  190.  
  191.  
  192. </span>
  193.  
  194.  
  195. <li class="buttons">
  196. <input type="hidden" name="form_id" value="492042" />
  197.  
  198. <input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
  199. </li>
  200. </ul>
  201. </form>
  202.  

config:

  1. $hostname = 'localhost';
  2. $dbname = 'test';
  3. $username = 'root';
  4. $password = '';
  5.  
  6.  
  7. mysql_connect($hostname, $username, $password) or DIE('Connection to host is failed, perhaps the service is down!');
  8.  
  9. mysql_select_db($dbname) or DIE('Database name is not available!');


wniosekforma.php :

  1. include 'config.inc';
  2.  
  3. header( 'Content-Type: text/html; charset=UTF-8' );
  4. header('Content-Type: text/html; charset=utf-8');
  5.  
  6. mysql_query("SET NAMES 'utf8'");
  7.  
  8.  
  9. $rokur = $_POST['rokuro'];
  10. $miesiacur = $_POST['miesiacuro'];
  11. $dzienur = $_POST['dzienuro'];
  12.  
  13. $datauro = "$rokur'-'$miesiacur'-'$dzienur";
  14.  
  15. $rokPLN = $_POST['dYY'];
  16. $miesiacPLN = $_POST['dMM'];
  17. $dzienPLN = $_POST['dDD'];
  18.  
  19. $dataPLN = "$rokPLN'-'$miesiacPLN'-'$dzienPLN";
  20.  
  21.  
  22. $sql = mysql_query("
  23. INSERT INTO wniosek (Imie,Nazwisko,pesel,ulica,miasto,kodpocztowy,dataurodzenia,miejsceurodzenia
    ,telefon,email,stopien,rokuzyskaniastopnia,adresodbioru,innyadres,czastrwaniakurs
    u,miejscekursu,dowodwplaty,dataprzelewu,daneosob,oswiadczenie) VALUES ('"
    .$_POST['Imie']."','".$_POST['Nazwisko']."','".$_POST['pesel']."','".$_POST['ulica']."','".$_POST['miasto']."','".$_POST['kodpocztowy']."','".$_POST['miasto']."',$datauro,'".$_POST['miejsceurodzenia']."','".$_POST['telefon']."','".$_POST['email']."','".$_POST['stopien']."','".$_POST['rokuzyskaniastopnia']."','".$_POST['adresodbioru']."','".$_POST['innyadres']."','".$_POST['czastrwaniakursu']."','".$_POST['miejscekursu']."','".$_POST['dowodwplaty']."',$dataPLN,'".$_POST['daneosob']."','".$_POST['oswiadczenie']."')") or die ('{"success":"false"}');



Pozdrawiam.
CuteOne
Chroń Panie Boże internet przed tworami takich "programistów"..
Ulysess
dane do wniosku są prawidłowo przesyłane , problem musi tkwić w pliku wniosekforma.php
mysql query SET UTF 8 umieszczasz po połaczeniu z baza.
umieszczają w zapytaniu dane bezpośrednio z POSTa - > to nie jest zbyt bezpieczne..
napisz jaki dokładnie jest problem ....
jaruzelskee
Problemem jest to, że dane nie zapisauja się w bazie.
szalek01
Lepiej poczytaj o sql-injection. A jeśli nie widzisz potrzeby powiedz gdzie ten formularz jest w sieci lub będze smile.gif
jaruzelskee
Dzięki za rady odnośnie bezpieczeństwa, ale tematem tego postu jest to czemu dane nie są przesyłane do bazy.
szalek01
Niestety nie mam czasu na kopiowanie tego i stawianie u siebie. Ale czy sprawdzałeś na jakim etapie się wywala ?
Zapisz sobie zapytanie do zmiennej i wykonaj je bezpośrednio w phpmyadminie może to na coś Cie naprowadzi (jeśli błąd jest tam)
Ulysess
a czy próbujesz problem sam rozwiązać czy czekasz tylko na gotowe rozwiązanie questionmark.gif ...

posprawdzaj wszystko po kolei czyli czy dane są poprawnie przesłane do drugiego pliku postem

później nie nie wykonuj zapytania tylko wpierw wyświetl i sprawdź czy wygląda prawidłowo
przy wykonywaniu zapytania użyj or die(mysql_error());
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.