Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Problem z formularzem w jquery
Forum PHP.pl > Forum > Przedszkole
przemo191
Witam, mam problem z formularzem.

Plik register.php
  1. <form id="formID" class="formular" method="post" action="register/add_user.php" style="width:450px">
  2. Rejestracja
  3. </legend>
  4. <span>*Imie: </span>
  5. <input value="" class="validate[required,custom[onlyLetterSp],maxSize[50],minSize[5]] text-input" type="text" name="rg_firstname" id="firstname" />
  6. </label>
  7. <span>*Nazwisko: </span>
  8. <input value="" class="validate[required,custom[onlyLetterNumber],maxSize[50],minSize[5]] text-input" type="text" name="rg_lastname" id="lastname" />
  9. </label>
  10. <span>*Email address: </span>
  11. <input value="" class="validate[required,custom[email]] text-input" type="text" name="rg_email" id="email" />
  12. </label><br />
  13. <span>*Login: </span>
  14. <input value="" class="validate[required,custom[onlyLetterNumber],maxSize[32],minSize[3]] text-input" type="text" name="rg_login" id="login" />
  15. </label>
  16. <span>*Hasło: </span>
  17. <input value="" class="validate[required,custom[onlyLetterNumber],maxSize[45],minSize[5]] text-input" type="password" name="rg_password" id="password" />
  18. </label>
  19. <span>*Potwierdź hasło: </span>
  20. <input value="" class="validate[required,equals[password]] text-input" type="password" name="rg_re_password" id="password" />
  21. </label>
  22. <input class="submit" type="submit" value="Zarejestruj"/>
  23. <input class="submit" type="reset" value="Wyczyść"/><hr/>
  24. </form>


Plik add_user.php
  1. $rg_login=$_POST['rg_login'];
  2. $rg_password=$_POST['rg_password'];
  3. $rg_re_password=$_POST['rg_re_password'];
  4. $rg_name=$_POST['rg_name'];
  5. $rg_lastname=$_POST['rg_lastname'];
  6. $rg_email=$_POST['rg_email'];
  7.  
  8. include("../db_pass.php");
  9. mysql_connect($host,$username,$password);
  10. mysql_select_db($database) or die("Nie odnaleziono bazy danych");
  11. $query="SELECT * FROM account";
  12. $result=mysql_query($query);
  13. $num = mysql_numrows($result);
  14. $i=0;
  15. while ($i < $num) {
  16. $baza_rg_login=mysql_result($result,$i,"login");
  17.  
  18. if($baza_rg_login == $rg_login){
  19. echo 'Taki login już istnieje, wprowadź inny</br></br>';
  20. echo '<form id="formID" class="formular" method="post" action="add_user.php" style="width:450px">
  21. <fieldset>
  22. <legend>
  23. Rejestracja
  24. </legend>
  25. <label>
  26. <span>*Imie: </span>
  27. <input value="'.$rg_name.'" class="validate[required,custom[onlyLetterSp],maxSize[50],minSize[5]] text-input" type="text" name="rg_firstname" id="firstname" />
  28. </label>
  29. <label>
  30. <span>*Nazwisko: </span>
  31. <input value="'.$rg_lastname.'" class="validate[required,custom[onlyLetterNumber],maxSize[50],minSize[5]] text-input" type="text" name="rg_lastname" id="lastname" />
  32. </label>
  33. <label>
  34. <span>*Email address: </span>
  35. <input value="'.$rg_email.'" class="validate[required,custom[email]] text-input" type="text" name="rg_email" id="email" />
  36. </label><br />
  37. <label>
  38. <span>*Login: </span>
  39. <input value="" class="validate[required,custom[onlyLetterNumber],maxSize[32],minSize[3]] text-input" type="text" name="rg_login" id="login" />
  40. </label>
  41. <label>
  42. <span>*Hasło: </span>
  43. <input value="" class="validate[required,custom[onlyLetterNumber],maxSize[45],minSize[5]] text-input" type="password" name="rg_password" id="password" />
  44. </label>
  45. <label>
  46. <span>*Potwierdź hasło: </span>
  47. <input value="" class="validate[required,equals[password]] text-input" type="password" name="rg_re_password" id="password" />
  48. </label>
  49. </fieldset>
  50. <input class="submit" type="submit" value="Zarejestruj"/><hr/>
  51. </form>';
  52. }else{
  53. if($rg_password == $rg_re_password){
  54. mysql_connect($host,$username,$password);
  55. @mysql_select_db($database) or die("Nie znaleziono bazy danych");
  56. $sha1password=sha1($rg_password);
  57. $query = "INSERT INTO account VALUES ('','$rg_login','$sha1password','$re_email','$rg_name','$rg_lastname')";
  58. $result=mysql_query($query);
  59.  
  60. echo 'Konto zostało dodane możesz się zalogować</br>';
  61. }else{
  62. echo 'Hasła nie są takie same!</br></br>';
  63. }
  64. }
  65.  
  66. $i++;
  67.  
  68. }


Problem polega na tym że:
1. kiedy wcisnę przycisk zarejestruj, to plik add_user.php dodaje do tabeli puste rekordy.
2. po wciśnięciu zarejestruj, formularz nie przenosi do pliku add_user.php

Może Wy mi pomożecie, bo ja już nie wiem o co chodzi.
CuteOne
Podstawy się kłaniają...

  1. $query= mysql_query("SELECT * FROM account WHERE login = '{$login}'");
  2.  
  3. if(mysql_num_rows($query) >= 1) {
  4.  
  5. // taki login istnieje.. pokaż formularz
  6. }
  7. else {
  8.  
  9. // zapis
  10. }
przemo191
Dzięki poprawiłem, to. Ale dalej nie przenosi mnie z pliku register.php do add_user.php, a w bazie dodaje puste rekordy.
gorden
  1. $query = "INSERT INTO account VALUES ('','$rg_login','$sha1password','$re_email','$rg_name','$rg_lastname')";


zgubiłeś coś tutaj. przejrzyj składnię klauzuli INSERT
przemo191
Z tym że kiedy wywołuję z paska adresu, add_user.php i na sztywno w zmienne wpisuje ciąg znaków do dodaje się prawidłowo.
Posio
Zrób jeden submit a restart jako zwykły button
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.