Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] formularz nie wysyła zer
fakenmr
post
Post #1





Grupa: Zarejestrowani
Postów: 26
Pomógł: 0
Dołączył: 23.09.2011

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


Witam mam formularz kontaktowy, który wysyła dane do bazy danych ale po wejściu do bazy danych ucina " 00 " zera

KOD PHP DO FORMULARZA:
  1. <?php
  2. if (!function_exists("GetSQLValueString")) {
  3. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  4. {
  5. if (PHP_VERSION < 6) {
  6. $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  7. }
  8.  
  9. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  10.  
  11. switch ($theType) {
  12. case "text":
  13. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  14. break;
  15. case "long":
  16. case "int":
  17. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  18. break;
  19. case "double":
  20. $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  21. break;
  22. case "date":
  23. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  24. break;
  25. case "defined":
  26. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  27. break;
  28. }
  29. return $theValue;
  30. }
  31. }
  32.  
  33. $editFormAction = $_SERVER['PHP_SELF'];
  34. if (isset($_SERVER['QUERY_STRING'])) {
  35. $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  36. }
  37.  
  38. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
  39.  
  40. if ($_POST['nr_nadania'] == '' || $_POST['imie_rekl'] == '' || $_POST['nazwisko_rekl'] == '' || $_POST['ulica_rekl'] == '' || $_POST['kod_poczt_rekl'] == '' || $_POST['miasto_rekl'] == '' || $_POST['tel_rekl'] == '' || $_POST['mail'] == '' || $_POST['tresc'] == '') {
  41.  
  42.  
  43. if($_POST['nr_nadania'] == '') {
  44.  
  45. $nr_nadania= 'Proszę wprowadzić nr nadania';
  46.  
  47. }
  48. if($_POST['imie_rekl'] == '' ) {
  49.  
  50. $imie_rekl = 'Proszę wprowadzić Imię';
  51. }
  52.  
  53. if($_POST['nazwisko_rekl'] == '') {
  54.  
  55. $nazwisko_rekl = 'Proszę wprowadzić Nazwisko';
  56. }
  57.  
  58. if($_POST['ulica_rekl'] == '') {
  59.  
  60. $ulica_rekl = 'Proszę wprowadzić Ulicę';
  61. }
  62.  
  63. if($_POST['kod_poczt_rekl'] == '') {
  64.  
  65. $kod_poczt_rekl = 'Proszę wprowadzić Kod Pocztowy';
  66. }
  67.  
  68. if($_POST['miasto_rekl'] == '') {
  69.  
  70. $miasto_rekl = 'Proszę wprowadzić Miasto';
  71. }
  72.  
  73. if($_POST['tel_rekl'] == '') {
  74.  
  75. $tel_rekl = 'Proszę wprowadzić Numer Telefonu';
  76. }
  77.  
  78. if($_POST['mail'] == '') {
  79.  
  80. $mail = 'Proszę wprowadzić Adres E-mail';
  81. }
  82.  
  83. if($_POST['tresc'] == '') {
  84.  
  85. $tresc = 'Proszę wprowadzić Treść Wiadomość';
  86. }
  87.  
  88.  
  89. }else {
  90.  
  91. $insertSQL = sprintf("INSERT INTO reklamacja (nr_nadania, imie_rekl, nazwisko_rekl, ulica_rekl, kod_poczt_rekl, miasto_rekl, tel_rekl, mail, tresc, tem_wiad) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
  92. GetSQLValueString($_POST['nr_nadania'], "varchar" ),
  93. GetSQLValueString($_POST['imie_rekl'], "text"),
  94. GetSQLValueString($_POST['nazwisko_rekl'], "text"),
  95. GetSQLValueString($_POST['ulica_rekl'], "text"),
  96. GetSQLValueString($_POST['kod_poczt_rekl'], "text"),
  97. GetSQLValueString($_POST['miasto_rekl'], "text"),
  98. GetSQLValueString($_POST['tel_rekl'], "int"),
  99. GetSQLValueString($_POST['mail'], "text"),
  100. GetSQLValueString($_POST['tresc'], "text"),
  101. GetSQLValueString($_POST['tem_wiad'], "int"));
  102.  
  103. mysql_select_db($database_config, $config);
  104. $Result1 = mysql_query($insertSQL, $config) or die(mysql_error());
  105.  
  106. $insertGoTo = "potw_wysl_kont.php";
  107. if (isset($_SERVER['QUERY_STRING'])) {
  108. $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  109. $insertGoTo .= $_SERVER['QUERY_STRING'];
  110.  
  111. }
  112. header(sprintf("Location: %s", $insertGoTo));
  113. }
  114. }
  115.  
  116. mysql_select_db($database_config, $config);
  117. $query_kontakt = "SELECT * FROM reklamacja ORDER BY `data` ASC";
  118. $kontakt = mysql_query($query_kontakt, $config) or die(mysql_error());
  119. $row_kontakt = mysql_fetch_assoc($kontakt);
  120. $totalRows_kontakt = mysql_num_rows($kontakt);
  121. ?>





FORMULARZ:


  1. <form action="<?php echo $editFormAction; ?>" name="form" method="POST" style="margin-top:10px;" >
  2. <table width="493" id="tbl_insert">
  3. <tr></tr>
  4. <tr>
  5. <th width="149" scope="col">&nbsp;</th>
  6. <th width="250" scope="col">Proszę wypenić wszystkie pola</th>
  7. </tr>
  8. <?php if(isset($nr_nadania)){?>
  9. <tr>
  10. <th>&nbsp;</th>
  11. <td class="wrn"><?php echo $nr_nadania; ?></td>
  12. </tr>
  13. <?php } ?>
  14. <tr>
  15. <th scope="row">Numer nadania</th>
  16. <td><input name="nr_nadania" type="text" class="frmfld" id="nr_nadania" value="<?php getSticky('nr_nadania'); ?>"></td>
  17.  
  18. </tr>
  19. <?php if(isset($imie_rekl)){?>
  20. <tr>
  21. <th>&nbsp;</th>
  22. <td class="wrn"><?php echo $imie_rekl; ?></td>
  23. </tr>
  24. <?php } ?>
  25. <tr>
  26. <th scope="row">Imię </th>
  27. <td><input name="imie_rekl" type="text" class="frmfld" id="imie_rekl" value="<?php getSticky('imie_rekl'); ?>"></td>
  28.  
  29. </tr>
  30. <?php if(isset($nazwisko_rekl)){?>
  31. <tr>
  32. <th>&nbsp;</th>
  33. <td class="wrn"><?php echo $nazwisko_rekl; ?></td>
  34. </tr>
  35. <?php } ?>
  36. <tr>
  37. <th scope="row">Nazwisko</th>
  38. <td><input name="nazwisko_rekl" type="text" class="frmfld" id="nazwisko_rekl" value="<?php getSticky('nazwisko_rekl'); ?>"></td>
  39.  
  40. </tr>
  41. <?php if(isset($ulica_rekl)){?>
  42. <tr>
  43. <th>&nbsp;</th>
  44. <td class="wrn"><?php echo $ulica_rekl; ?></td>
  45. </tr>
  46. <?php } ?>
  47. <tr>
  48. <th scope="row">Ulica</th>
  49. <td><input name="ulica_rekl" type="text" class="frmfld" id="ulica_rekl" value="<?php getSticky('ulica_rekl'); ?>"></td>
  50. </tr>
  51. <?php if(isset($kod_poczt_rekl)){?>
  52. <tr>
  53. <th>&nbsp;</th>
  54. <td class="wrn"><?php echo $kod_poczt_rekl; ?></td>
  55. </tr>
  56. <?php } ?>
  57. <tr>
  58. <th scope="row">Kod Pocztowy</th>
  59. <td><input name="kod_poczt_rekl" type="text" class="frmfld" id="kod_poczt_rekl" value="<?php getSticky('kod_poczt_rekl'); ?>"></td>
  60.  
  61. </tr>
  62. <?php if(isset($miasto_rekl)){?>
  63. <tr>
  64. <th>&nbsp;</th>
  65. <td class="wrn"><?php echo $miasto_rekl; ?></td>
  66. </tr>
  67. <?php } ?>
  68. <tr>
  69. <th scope="row">Miasto</th>
  70. <td><input name="miasto_rekl" type="text" class="frmfld" id="miasto_rekl" value="<?php getSticky('miasto_rekl'); ?>"></td>
  71.  
  72. </tr>
  73. <?php if(isset($mail)){?>
  74. <tr>
  75. <th>&nbsp;</th>
  76. <td class="wrn"><?php echo $mail; ?></td>
  77. </tr>
  78. <?php } ?>
  79. <tr>
  80. <th scope="row">E-mail</th>
  81. <td><input name="mail" type="text" class="frmfld" id="mail" value="<?php getSticky('mail'); ?>"></td>
  82.  
  83. </tr>
  84. <?php if(isset($tel_rekl)){?>
  85. <tr>
  86. <th>&nbsp;</th>
  87. <td class="wrn"><?php echo $tel_rekl; ?></td>
  88. </tr>
  89. <?php } ?>
  90. <tr>
  91. <th scope="row">Telefon</th>
  92. <td><input name="tel_rekl" type="text" class="frmfld" id="tel_rekl" value="<?php getSticky('tel_rekl'); ?>"></td>
  93.  
  94. </tr>
  95. <tr>
  96.  
  97. </tr>
  98. <th scope="row">Temat</th>
  99. <td><select name="tem_wiad" class="frmfld"><?
  100. foreach ($_tem_wiad as $k=>$w)
  101. {
  102. echo'<option value="'.$k.'">'.$w.'</option>';
  103. }?>
  104. </select>
  105. <br></td>
  106.  
  107. </tr>
  108. <?php if(isset($tresc)){?>
  109. <tr>
  110. <th>&nbsp;</th>
  111. <td class="wrn"><?php echo $tresc; ?></td>
  112. </tr>
  113. <?php } ?>
  114. <tr>
  115. <th scope="row">Treść</th>
  116. <td><textarea name="tresc" class="frmfld" id="tresc" value="<?php getSticky('tresc'); ?>"></textarea></td>
  117.  
  118. </tr>
  119. <tr>
  120. <th scope="row">&nbsp;</th>
  121.  
  122. <td><input name="btn" type="image" src="images/menu/wyslij.png" id="btn" style="width: 100px;float:right;" value="Wyślij" /></td>
  123. </tr>
  124. </table>
  125. <input type="hidden" name="MM_insert" value="form">
  126. </form>



BAZA DANYCH KTÓRA TWORZYŁEM
  1. CREATE TABLE `reklamacja` (
  2. `wiad_id` int(11) NOT NULL AUTO_INCREMENT,
  3. `nr_nadania` varchar(20) collate utf8_polish_ci NOT NULL,
  4. `imie_rekl` varchar(15) character SET utf8 NOT NULL,
  5. `nazwisko_rekl` varchar(30) character SET utf8 NOT NULL,
  6. `ulica_rekl` varchar(50) character SET utf8 NOT NULL,
  7. `kod_poczt_rekl` varchar(11) character SET utf8 NOT NULL,
  8. `miasto_rekl` varchar(11) character SET utf8 NOT NULL,
  9. `tel_rekl` int(13) NOT NULL,
  10. `mail` varchar(40) collate utf8_polish_ci NOT NULL,
  11. `data` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  12. `tresc` text collate utf8_polish_ci NOT NULL,
  13. `tem_wiad` int(1) NOT NULL,
  14. PRIMARY KEY (`wiad_id`),
  15. UNIQUE KEY `nr_nadania` (`nr_nadania`)
  16. ) ENGINE=MyISAM AUTO_INCREMENT=72 DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci AUTO_INCREMENT=72 ;
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: 21.08.2025 - 05:13