Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php][mysql] Rejestracja mam błąd
jacus24
post
Post #1





Grupa: Zarejestrowani
Postów: 133
Pomógł: 0
Dołączył: 15.12.2007

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


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. ?>
Go to the top of the page
+Quote Post
oomaster
post
Post #2





Grupa: Zarejestrowani
Postów: 305
Pomógł: 3
Dołączył: 4.08.2006
Skąd: GDA

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


nie jestem orłem w PHP ale w tym kodzie to else byt często i dziwnie występuje (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)

Ja bym inaczej rozwiązał ten skrypt, metodą na skróty chociaż też elegancko to by wyglądało.
Go to the top of the page
+Quote Post
vtuner
post
Post #3





Grupa: Zarejestrowani
Postów: 220
Pomógł: 10
Dołączył: 23.08.2005
Skąd: Łódź

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


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
Go to the top of the page
+Quote Post
jacus24
post
Post #4





Grupa: Zarejestrowani
Postów: 133
Pomógł: 0
Dołączył: 15.12.2007

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


To nie to
  1. <?php
  2. [b]Parse error[/b]: parse error in [b]c:usrkrasnalwww&#092;testrejestracja.php[/b] on line 82
  3. ?>
Go to the top of the page
+Quote Post
Lejto
post
Post #5





Grupa: Zarejestrowani
Postów: 1 385
Pomógł: 48
Dołączył: 23.05.2007

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


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. ?>


Ten post edytował Lejto 7.03.2008, 20:02:13
Go to the top of the page
+Quote Post
vtuner
post
Post #6





Grupa: Zarejestrowani
Postów: 220
Pomógł: 10
Dołączył: 23.08.2005
Skąd: Łódź

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


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. ?>


Ten post edytował vtuner 7.03.2008, 20:06:26
Go to the top of the page
+Quote Post
jacus24
post
Post #7





Grupa: Zarejestrowani
Postów: 133
Pomógł: 0
Dołączył: 15.12.2007

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


Dalej jest ten sam błąd. Nie wiem czy za dużo jest { czy co?
Go to the top of the page
+Quote Post
Lejto
post
Post #8





Grupa: Zarejestrowani
Postów: 1 385
Pomógł: 48
Dołączył: 23.05.2007

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


zrobiłeś jak ja i vtuner ci pokazaliśmy?
Go to the top of the page
+Quote Post
jacus24
post
Post #9





Grupa: Zarejestrowani
Postów: 133
Pomógł: 0
Dołączył: 15.12.2007

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


ok już działa dzięki za pomoc
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 15:37