Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Formularze, puste pola i fajnu bug
Jarod
post
Post #1





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


Witam!

Testuje pewien system. Natrafiłem na ciekawy problem z którym nie mogę sobie poradzić. Załóżmy że mamy pewien formularz rejestracyjny (zawiera pola: login, hasło, imie nazwisko, telefon), z czego pole telefon nie jest wymagane do wypełnienia. Jeśli użytkownik poda telefon to jest ok. Ale jeśli nie poda, a chce edytować swoje dane to w miejscu telefon pojawia się size="15"..

Oto kawałek kodu:
  1. (...)
  2. <?php
  3. //Zapytanie o dane personalne pracownika
  4. $query = &#092;"SELECT login, imie, nazwisko, pesel, email, ulica, kod, miejscowosc, telefo
    n
  5. \".
  6.  \"FROM konto, pracownik WHERE login='\".$_SESSION['nick'].\"' AND konto.konto_id=pracownik.konto_id;\";
  7. $result = mysql_query($query)
  8. or die (\"Zapytanie nieudane! BŁĄD: \".mysql_error());
  9. $query_data = mysql_fetch_row($result);
  10.  
  11. //Zamknięcie połączenia z bazą danych
  12. mysql_close($conn);
  13. ?>
  14.  
  15. <table width=\"90%\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">
  16.  <tr>
  17.  <td>
  18.  <!-- formularz -->
  19.  <form action=\"start.php?opcja=1011&<?=SID?>\" method=\"post\">
  20.  
  21.  <table width=\"70%\" align=\"left\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
  22. <tr>
  23. <td class=\"tdbkground\"><span style=\"color: red; font-size: 9px\">*</span><strong>LOGIN: (max.15 znaków)</strong></td>
  24. <td class=\"tdbkground\"><input type=\"text\" name=\"login\" value=<?=$query_data[0]?> size=\"15\" maxlength=\"15\" /></td>
  25. </tr>
  26. <tr>
  27. <td class=\"tdbkground\"><span style=\"color: red; font-size: 9px\">*</span><strong>Hasło: (max. 35 znaków)</strong></td>
  28. <td class=\"tdbkground\"><input type=\"password\" name=\"haslo\" value=\"\" size=\"35\" maxlength=\"35\" /></td>
  29. </tr>
  30. <tr>
  31. <td class=\"tdbkground\"><span style=\"color: red; font-size: 9px\">*</span><strong>Powtórz hasło:</strong></td>
  32. <td class=\"tdbkground\"><input type=\"password\" name=\"haslo2\" value=\"\" size=\"35\" maxlength=\"35\" /></td>
  33. </tr>
  34.  </table>
  35.  </td>
  36.  </tr>
  37.  <tr>
  38.  <td>
  39.  <table width=\"100%\" align=\"left\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
  40. <tr>
  41. <td class=\"tdbkground\"><span style=\"color: red; font-size: 9px\">*</span><strong>Imię:</strong></td>
  42. <td class=\"tdbkground\"><input type=\"text\" name=\"imie\" value=<?=$query_data[1]?> size=\"20\" maxlength=\"20\" /></td>
  43. <td class=\"tdbkground\"><span style=\"color: red; font-size: 9px\">*</span><strong>Nazwisko:</strong></td>
  44. <td class=\"tdbkground\"><input type=\"text\" name=\"nazwisko\" value=<?=$query_data[2]?> size=\"25\" maxlength=\"25\" /></td>
  45. </tr>
  46. <tr>
  47. <td class=\"tdbkground\"><strong>Pesel:</strong></td>
  48. <td class=\"tdbkground\"><input type=\"text\" name=\"pesel\" value=<?=$query_data[3]?> size=\"11\" maxlength=\"11\" /></td>
  49. <td class=\"tdbkground\"><strong>E-mail:</strong></td>
  50. <td class=\"tdbkground\"><input type=\"text\" name=\"email\" value=<?=$query_data[4]?> size=\"20\" maxlength=\"40\" /></td>
  51. </tr>
  52. <tr>
  53. <td class=\"tdbkground\"><strong>Ulica:</strong></td>
  54. <td class=\"tdbkground\"><input type=\"text\" name=\"ulica\" value=<?=$query_data[5]?> size=\"35\" maxlength=\"60\" /></td>
  55. </tr>
  56. <tr>
  57. <td class=\"tdbkground\"><strong>Kod pocztowy:</strong></td>
  58. <td class=\"tdbkground\"><input type=\"text\" name=\"kod\" value=<?=$query_data[6]?> size=\"6\" maxlength=\"6\" /></td>
  59. <td class=\"tdbkground\"><strong>Miejscowość:</strong></td>
  60. <td class=\"tdbkground\"><input type=\"text\" name=\"miejscowosc\" value=<?=$query_data[7]?> size=\"25\" maxlength=\"40\" /></td>
  61. </tr>
  62. <tr>
  63. <td class=\"tdbkground\"><span style=\"color: red; font-size: 9px\">*</span><strong>Telefon:</strong></td>
  64. <td class=\"tdbkground\"><input type=\"text\" name=\"telefon\" value=<?=$query_data[8]?> size=\"15\" maxlength=\"20\" /></td>
  65. </tr>
  66.  </table>
  67.  </td>
  68.  </tr>
  69.  <tr>
  70.  <td>
  71.  <table width=\"100%\" align=\"center\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">
  72. <tr>
  73. <td colspan=\"2\"><span style=\"color: red; font-size: 12px\">* </span><span style=\"color: blue; font-size: 12px\">- pola obowiązkowe</span></td>
  74. </tr>
  75. <tr>
  76. <td width=\"50%\"align=\"right\"><input type=\"Button\" name=\"Button\" value=\"Rezygnuję\" onClick=\"location.href='start.php?opcja=0&<?=SID?>'\"></td>
  77. <td><input type=\"Submit\" name=\"Button\" value=\"Zapisz\"</td>
  78. </tr>
  79.  </table>
  80.  </form>
  81.  <!-- koniec formularza -->
  82.  </td>
  83.  </tr>
  84. </table>


Dzieje się tak ponieważ np query_data[2] jest puste bo w bazie nie było żadnych informacjii.. Nie wiem jak ten problem rozwiązać..


--------------------
”Godzina nauki w życiu nowoczesnego apostoła jest godziną modlitwy.”
(św. Josemaría Escrivá, Droga, 335)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
czachor
post
Post #2





Grupa: Zarejestrowani
Postów: 897
Pomógł: 40
Dołączył: 16.12.2003
Skąd: Warszawa

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


value="" - wartości w cudzysłowach powinny być.


--------------------
how many SEO experts does it take to change a light bulb,lightbulb,light,bulb,lamp,lighting,switch,sex,xxx
5-Reasons-why-you-should-NEVER-fix-a-computer-for-free
Go to the top of the page
+Quote Post
Jarod
post
Post #3





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


Cytat(czachor @ 2005-06-17 18:31:52)
value="" - wartości w cudzysłowach powinny być.

Serdeczne dzięki!

pozdrawiam


--------------------
”Godzina nauki w życiu nowoczesnego apostoła jest godziną modlitwy.”
(św. Josemaría Escrivá, Droga, 335)
Go to the top of the page
+Quote Post

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 - 11:34