Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: [php][mysql] Rejestracja mam b³±d
Forum PHP.pl > Forum > Przedszkole
jacus24
Próbujê zrobiæ sobie rejestracja ale mam b³±d w lini 82 .
  1. <?php
  2. include "conn.inc.php";
  3. ?>
  4.  
  5. <?php
  6. if (isset ($_POST['submit'])) {
  7. if ($_POST['login'] != "" &&
  8. $_POST['haslo'] != "" &&
  9. $_POST['haslo2'] == $_POST['haslo'] &&
  10. $_POST['regulamin'] != "" &&
  11. $_POST['email'] !== "" ) {
  12.  
  13. $query = "SELECT login 
  14. FROM uzytkownicy
  15. WHERE login = '".$_POST['login']."' "; 
  16. $result = mysql_query($query)
  17. or die (mysql_error()); 
  18.  
  19. if (mysql_num_rows($result) != 0 ) 
  20. ?>
  21.  
  22. Nazwa u¿ytkownika <?php echo $_POST['login']; ?> jest ju¿ zajêta, proszê wybraæ inn±!
  23.  
  24. <form action="rejestracja.php" method="post">
  25. Login <input type="text" name="login" size="20" maxlength="40">
  26. Has³o <input type="password" name="haslo" size="20" maxlength="40">
  27. Powtórz has³o <input type="password" name="haslo_2" size="20" maxlength="40" >
  28. Email <input type="text" name="email" size="20" maxlength="40" >
  29. <input type="checkbox" name="regulamin" value="tak" > Akceptujê&nbsp;<a href="regulamin.php">regulamin</a>
  30. <?php $today = date("Y-m-d"); ?>
  31. <input type="submit" name="submit" value="Zarejestruj" >
  32. <input type="reset" value="Wyczy¶æ"></form>
  33.  
  34. <?php
  35. } else {
  36.  
  37. if ($_POST['haslo_2'] != $_POST['haslo']) {
  38. ?>
  39.  
  40. Podane has³a s± ró¿ne!
  41.  
  42. <?php
  43.  
  44. } else {
  45.  
  46. $query = "INSERT INTO `uzytkownicy` (login, haslo, haslo_2, email, today)
  47. VALUES (
  48. '".$_POST['login']."',
  49. '".$_POST['haslo']."',
  50. '".$_POST['haslo_2']."',
  51. '".$_POST['email']."',
  52. '".date("Y-m-d")."'
  53. );";
  54.  
  55. if (mysql_query($query) == 1) {
  56.  
  57. $_SESSION['user_logged'] = $_POST['login'];
  58. $_SESSION['user_password'] = $_POST['haslo'];
  59. ?>
  60.  
  61. Dziêkujemy za zarejestrowanie sie <?php echo $_POST['login']; ?> Kliknij <a href="index.php">tutaj</a> aby przej¶æ do strony g³ównej.
  62.  
  63. <?php
  64. } else {
  65. ?>
  66.  
  67. Wype³nij wszystkie pola.
  68.  
  69. <form action="rejestracja.php" method="post">
  70. Login <input type="text" name="login" size="20" maxlength="40">
  71. Has³o <input type="password" name="haslo" size="20" maxlength="40">
  72. Powtórz has³o <input type="password" name="haslo_2" size="20" maxlength="40" >
  73. Email <input type="text" name="email" size="20" maxlength="40" >
  74. <input type="checkbox" name="regulamin" value="tak" > Akceptujê&nbsp;<a href="regulamin.php">regulamin</a>
  75. <?php $today = date("Y-m-d"); ?>
  76. <input type="submit" name="submit" value="Zarejestruj" >
  77. <input type="reset" value="Wyczy¶æ"></form>
  78.  
  79. <?php
  80. } else {
  81. ?>
  82.  
  83. Witamy na stronie rejestracji
  84.  
  85. <form action="rejestracja.php" method="post">
  86. Login <input type="text" name="login" size="20" maxlength="40">
  87. Has³o <input type="password" name="haslo" size="20" maxlength="40">
  88. Powtórz has³o <input type="password" name="haslo_2" size="20" maxlength="40" >
  89. Email <input type="text" name="email" size="20" maxlength="40" >
  90. <input type="checkbox" name="regulamin" value="tak" > Akceptujê&nbsp;<a href="regulamin.php">regulamin</a>
  91. <?php $today = date("Y-m-d"); ?>
  92. <input type="submit" name="submit" value="Zarejestruj" >
  93. <input type="reset" value="Wyczy¶æ"></form>
  94.  
  95. <?php
  96. }
  97. ?>
oomaster
nie jestem or³em w PHP ale w tym kodzie to else byt czêsto i dziwnie wystêpuje tongue.gif

Ja bym inaczej rozwi±za³ ten skrypt, metod± na skróty chocia¿ te¿ elegancko to by wygl±da³o.
vtuner
W linii 82 zamiast:
  1. <?php
  2. } else {
  3. ?>

wpisz:
  1. <?php
  2. }} else {
  3. ?>


powinno pomóc choæ nie jestem pewien, skoro nie poda³e¶ komunikatu b³êdu
jacus24
To nie to
  1. <?php
  2. [b]Parse error[/b]: parse error in [b]c:usrkrasnalwww&#092;testrejestracja.php[/b] on line 82
  3. ?>
Lejto
zobacz tak:
  1. <?php
  2. include "conn.inc.php";
  3. ?>
  4.  
  5. <?php
  6. if (isset ($_POST['submit'])) {
  7. if ($_POST['login'] != "" &&
  8. $_POST['haslo'] != "" &&
  9. $_POST['haslo2'] == $_POST['haslo'] &&
  10. $_POST['regulamin'] != "" &&
  11. $_POST['email'] !== "" ) {
  12.  
  13. $query = "SELECT login 
  14. FROM uzytkownicy
  15. WHERE login = '".$_POST['login']."' "; 
  16. $result = mysql_query($query)
  17. or die (mysql_error()); 
  18.  
  19. if (mysql_num_rows($result) != 0 ) 
  20. ?>
  21.  
  22. Nazwa użytkownika <?php echo $_POST['login']; ?> jest już zajęta, proszę wybrać inną!
  23.  
  24. <form action="rejestracja.php" method="post">
  25. Login <input type="text" name="login" size="20" maxlength="40">
  26. Hasło <input type="password" name="haslo" size="20" maxlength="40">
  27. Powtórz hasło <input type="password" name="haslo_2" size="20" maxlength="40" >
  28. Email <input type="text" name="email" size="20" maxlength="40" >
  29. <input type="checkbox" name="regulamin" value="tak" > Akceptuję&nbsp;<a href="regulamin.php">regulamin</a>
  30. <?php $today = date("Y-m-d"); ?>
  31. <input type="submit" name="submit" value="Zarejestruj" >
  32. <input type="reset" value="Wyczyść"></form>
  33.  
  34. <?php
  35. } 
  36. }
  37. else {
  38.  
  39. if ($_POST['haslo_2'] != $_POST['haslo']) {
  40. ?>
  41.  
  42. Podane hasła są różne!
  43.  
  44. <?php
  45.  
  46. } else {
  47.  
  48. $query = "INSERT INTO `uzytkownicy` (login, haslo, haslo_2, email, today)
  49. VALUES (
  50. '".$_POST['login']."',
  51. '".$_POST['haslo']."',
  52. '".$_POST['haslo_2']."',
  53. '".$_POST['email']."',
  54. '".date("Y-m-d")."'
  55. );";
  56.  
  57. if (mysql_query($query) == 1) {
  58.  
  59. $_SESSION['user_logged'] = $_POST['login'];
  60. $_SESSION['user_password'] = $_POST['haslo'];
  61. ?>
  62.  
  63. Dziękujemy za zarejestrowanie sie <?php echo $_POST['login']; ?> Kliknij <a href="index.php">tutaj</a> aby przejść do strony głównej.
  64.  
  65. <?php
  66. } else {
  67. ?>
  68.  
  69. Wypełnij wszystkie pola.
  70.  
  71. <form action="rejestracja.php" method="post">
  72. Login <input type="text" name="login" size="20" maxlength="40">
  73. Hasło <input type="password" name="haslo" size="20" maxlength="40">
  74. Powtórz hasło <input type="password" name="haslo_2" size="20" maxlength="40" >
  75. Email <input type="text" name="email" size="20" maxlength="40" >
  76. <input type="checkbox" name="regulamin" value="tak" > Akceptuję&nbsp;<a href="regulamin.php">regulamin</a>
  77. <?php $today = date("Y-m-d"); ?>
  78. <input type="submit" name="submit" value="Zarejestruj" >
  79. <input type="reset" value="Wyczyść"></form>
  80.  
  81. <?php
  82. } else {
  83. ?>
  84.  
  85. Witamy na stronie rejestracji
  86.  
  87. <form action="rejestracja.php" method="post">
  88. Login <input type="text" name="login" size="20" maxlength="40">
  89. Hasło <input type="password" name="haslo" size="20" maxlength="40">
  90. Powtórz hasło <input type="password" name="haslo_2" size="20" maxlength="40" >
  91. Email <input type="text" name="email" size="20" maxlength="40" >
  92. <input type="checkbox" name="regulamin" value="tak" > Akceptuję&nbsp;<a href="regulamin.php">regulamin</a>
  93. <?php $today = date("Y-m-d"); ?>
  94. <input type="submit" name="submit" value="Zarejestruj" >
  95. <input type="reset" value="Wyczyść"></form>
  96.  
  97. <?php
  98. }
  99. ?>
vtuner
Teraz będzie dobrze. Wystarczy uporządkować sobie kod:

  1. <?php
  2. include "conn.inc.php";
  3.  
  4. if (isset ($_POST['submit'])) 
  5. {
  6. if ($_POST['login'] != "" && $_POST['haslo'] != "" && $_POST['haslo2'] == $_POST['haslo'] && $_POST['regulamin'] != "" && $_POST['email'] !== "" ) 
  7. {
  8. $query = "SELECT login 
  9. FROM uzytkownicy
  10. WHERE login = '".$_POST['login']."' "; 
  11. $result = mysql_query($query)
  12. or die (mysql_error()); 
  13.  
  14. if (mysql_num_rows($result) != 0 ) 
  15. {
  16. ?>
  17.  
  18. Nazwa użytkownika <?php echo $_POST['login']; ?> jest już zajęta, proszę wybrać inną!
  19.  
  20. <form action="rejestracja.php" method="post">
  21. Login <input type="text" name="login" size="20" maxlength="40">
  22. Hasło <input type="password" name="haslo" size="20" maxlength="40">
  23. Powtórz hasło <input type="password" name="haslo_2" size="20" maxlength="40" >
  24. Email <input type="text" name="email" size="20" maxlength="40" >
  25. <input type="checkbox" name="regulamin" value="tak" > Akceptuję&nbsp;<a href="regulamin.php">regulamin</a>
  26. <?php $today = date("Y-m-d"); ?>
  27. <input type="submit" name="submit" value="Zarejestruj" >
  28. <input type="reset" value="Wyczyść"></form>
  29.  
  30. <?php
  31. } 
  32. }
  33. else 
  34. {
  35.  
  36. if ($_POST['haslo_2'] != $_POST['haslo']) 
  37. {
  38. ?>
  39.  
  40. Podane hasła są różne!
  41.  
  42. <?php
  43. } else {
  44.  
  45. $query = "INSERT INTO `uzytkownicy` (login, haslo, haslo_2, email, today)
  46. VALUES (
  47. '".$_POST['login']."',
  48. '".$_POST['haslo']."',
  49. '".$_POST['haslo_2']."',
  50. '".$_POST['email']."',
  51. '".date("Y-m-d")."'
  52. );";
  53.  
  54. if (mysql_query($query) == 1) 
  55. {
  56. $_SESSION['user_logged'] = $_POST['login'];
  57. $_SESSION['user_password'] = $_POST['haslo'];
  58. ?>
  59.  
  60. Dziękujemy za zarejestrowanie sie <?php echo $_POST['login']; ?> Kliknij <a href="index.php">tutaj</a> aby przejść do strony głównej.
  61.  
  62. <?php
  63. } else {
  64. ?>
  65.  
  66. Wypełnij wszystkie pola.
  67.  
  68. <form action="rejestracja.php" method="post">
  69. Login <input type="text" name="login" size="20" maxlength="40">
  70. Hasło <input type="password" name="haslo" size="20" maxlength="40">
  71. Powtórz hasło <input type="password" name="haslo_2" size="20" maxlength="40" >
  72. Email <input type="text" name="email" size="20" maxlength="40" >
  73. <input type="checkbox" name="regulamin" value="tak" > Akceptuję&nbsp;<a href="regulamin.php">regulamin</a>
  74. <?php $today = date("Y-m-d"); ?>
  75. <input type="submit" name="submit" value="Zarejestruj" >
  76. <input type="reset" value="Wyczyść"></form>
  77.  
  78. <?php
  79. } 
  80. }
  81. } 
  82. } else {
  83. ?>
  84.  
  85. Witamy na stronie rejestracji
  86.  
  87. <form action="rejestracja.php" method="post">
  88. Login <input type="text" name="login" size="20" maxlength="40">
  89. Hasło <input type="password" name="haslo" size="20" maxlength="40">
  90. Powtórz hasło <input type="password" name="haslo_2" size="20" maxlength="40" >
  91. Email <input type="text" name="email" size="20" maxlength="40" >
  92. <input type="checkbox" name="regulamin" value="tak" > Akceptuję&nbsp;<a href="regulamin.php">regulamin</a>
  93. <?php $today = date("Y-m-d"); ?>
  94. <input type="submit" name="submit" value="Zarejestruj" >
  95. <input type="reset" value="Wyczyść"></form>
  96.  
  97. <?php
  98. }
  99. ?>
jacus24
Dalej jest ten sam b³±d. Nie wiem czy za du¿o jest { czy co?
Lejto
zrobi³e¶ jak ja i vtuner ci pokazali¶my?
jacus24
ok ju¿ dzia³a dziêki za pomoc
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.