Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Problem z formularzem w jquery
przemo191
post 13.10.2011, 13:26:18
Post #1





Grupa: Zarejestrowani
Postów: 154
Pomógł: 3
Dołączył: 1.08.2011

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


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.

Ten post edytował przemo191 13.10.2011, 13:27:32
Go to the top of the page
+Quote Post
CuteOne
post 13.10.2011, 16:08:38
Post #2





Grupa: Zarejestrowani
Postów: 2 958
Pomógł: 574
Dołączył: 23.09.2008
Skąd: wiesz, że tu jestem?

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


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. }
Go to the top of the page
+Quote Post
przemo191
post 13.10.2011, 16:46:50
Post #3





Grupa: Zarejestrowani
Postów: 154
Pomógł: 3
Dołączył: 1.08.2011

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


Dzięki poprawiłem, to. Ale dalej nie przenosi mnie z pliku register.php do add_user.php, a w bazie dodaje puste rekordy.
Go to the top of the page
+Quote Post
gorden
post 13.10.2011, 16:59:33
Post #4





Grupa: Zarejestrowani
Postów: 486
Pomógł: 101
Dołączył: 27.06.2010

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


  1. $query = "INSERT INTO account VALUES ('','$rg_login','$sha1password','$re_email','$rg_name','$rg_lastname')";


zgubiłeś coś tutaj. przejrzyj składnię klauzuli INSERT
Go to the top of the page
+Quote Post
przemo191
post 13.10.2011, 17:29:56
Post #5





Grupa: Zarejestrowani
Postów: 154
Pomógł: 3
Dołączył: 1.08.2011

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


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.
Go to the top of the page
+Quote Post
Posio
post 13.10.2011, 21:52:33
Post #6





Grupa: Zarejestrowani
Postów: 417
Pomógł: 44
Dołączył: 23.06.2011

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


Zrób jeden submit a restart jako zwykły button
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 Wersja Lo-Fi Aktualny czas: 12.06.2025 - 17:24