Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [MYSQL]Dodawanie do bazy
Forum PHP.pl > Forum > Przedszkole
Dizzy
  1. <img src="Grafika/podstrony/rejestracja.gif"><br><br>
  2. <?
  3. include 'Konfiguracja/Konfiguracja.php';
  4. if ($register == "on")
  5. {
  6. if (!isset($_POST['send'])) { // Sprawdzanie czy formularz zostal wyslany
  7. echo "<form action='index.php?show=Rejestruj' method=post>
  8.      <table>
  9.      <tr><td>Login:</td> <td><input type=\"text\" name=\"login\"> <font color=\"#FF0000\">*</font></td></tr>
  10.      <tr><td>Hasło:</td> <td><input type=\"password\" name=\"haslo1\"> <font color=\"#FF0000\">*</font></td></tr>
  11.      <tr><td>Powtórz Hasło:</td> <td><input type=\"password\" name=\"haslo2\"> <font color=\"#FF0000\">*</font></td></tr>
  12.      <tr><td>E-mail: <td><input type=\"text\" name=\"mail\"> <font color=\"#FF0000\">*</font></td></tr>
  13.      <tr><td>GG: <td><input type=\"text\" name=\"gg\"></td></tr>
  14.      <tr><td>Token:<td><img src='obrazek.php' width=\"120\" height=\"15\" alt=''></td></tr>
  15.      <tr><td><td><input type=\"text\" name=\"token\"> <font color=\"#FF0000\">*</font></td></tr>
  16.      </table><br><font color=\"#FF0000\">*</font> - Pola wymagane<br><br>
  17.      <input type=submit name=\"send\" value=\"Zarejestruj mnie\">
  18.      </form><br>";
  19.  
  20. } else {
  21. $user_login = $_POST['login'];
  22. $user_pass1 = $_POST['haslo1'];
  23. $user_pass2 = $_POST['haslo2'];
  24. $user_mail = $_POST['mail'];
  25. $user_gg = $_POST['gg'];
  26. if($_POST['token'] == $_SESSION['token'])
  27. { echo "Token przepisany poprawnie<br>"; }
  28. else
  29. { echo"Błędnie przepisany token!<br>"; }
  30.    if(!empty($user_login) && !empty($user_pass1) && !empty($user_pass2) && !empty($user_mail)){    //oraz czy uzupełniono wszystkie dane
  31.        if ($user_pass1 == $user_pass2) {
  32.         $check_query = mysql_query("SELECT * FROM users WHERE user_login='$user_login'");
  33.        if(mysql_num_rows($check_query)==1) { echo 'Uzytkownik juz istnieje.'; }
  34.        else{
  35.            $password = md5(md5($user_pass1));
  36.            $q = "INSERT INTO users (user_id, user_login, user_haslo, user_mail, user_gg, user_type) VALUES (0 , '$user_login' , '$password' , '$user_mail' , '$user_gg', '0')"; // zapisywanie rekordu do bazy
  37.            if (@mysql_query ($q)) {
  38.            echo "Konto załozono poprawnie.";
  39.            } else {
  40.            echo "Konto niemoze byc utworzone " . mysql_error() . ""; }
  41.            }
  42.        } else { echo 'Podane hasla nie zgadzaja sie'; }
  43.    }
  44.    else { echo "Nie uzupełniono wszystkich pól!!!"; }
  45. }
  46. mysql_close(); //zamykanie połączenia z bazą
  47. }
  48. elseif ($register == "off")
  49. {
  50. echo "Rejestracja wyłączona!";
  51. }
  52. else
  53. {
  54. print 'Błąd konfiguracji!';
  55. }
  56.  
  57.  
  58. ?>

Mój problem polega na tym że gdy sie wpisze źle token to konto sie i tak doda do bazy (Lecz pisze ze Token jest niepoprawny)
Gdy jets poprawny token to dodaje równiez (Więc to jest dobrze)
Uważam że problem polega na:
  1. <?php
  2. if($_POST['token'] == $_SESSION['token'])
  3. { echo "Token przepisany poprawnie<br>"; }
  4. else
  5. { echo"Błędnie przepisany token!<br>"; }
  6. ?>

Niebardzo wiem jak i gdzie to zamiescic...
Czekam na waszą pomoc.
czarnowidz
Ja bym spróbował tak :
  1. <img src="Grafika/podstrony/rejestracja.gif"><br><br>
  2. <?
  3. include 'Konfiguracja/Konfiguracja.php';
  4. if ($register == "on")
  5. {
  6. if (!isset($_POST['send'])) { // Sprawdzanie czy formularz zostal wyslany
  7. echo "<form action='index.php?show=Rejestruj' method=post>
  8.     <table>
  9.     <tr><td>Login:</td> <td><input type=\"text\" name=\"login\"> <font color=\"#FF0000\">*</font></td></tr>
  10.     <tr><td>Hasło:</td> <td><input type=\"password\" name=\"haslo1\"> <font color=\"#FF0000\">*</font></td></tr>
  11.     <tr><td>Powtórz Hasło:</td> <td><input type=\"password\" name=\"haslo2\"> <font color=\"#FF0000\">*</font></td></tr>
  12.     <tr><td>E-mail: <td><input type=\"text\" name=\"mail\"> <font color=\"#FF0000\">*</font></td></tr>
  13.     <tr><td>GG: <td><input type=\"text\" name=\"gg\"></td></tr>
  14.     <tr><td>Token:<td><img src='obrazek.php' width=\"120\" height=\"15\" alt=''></td></tr>
  15.     <tr><td><td><input type=\"text\" name=\"token\"> <font color=\"#FF0000\">*</font></td></tr>
  16.     </table><br><font color=\"#FF0000\">*</font> - Pola wymagane<br><br>
  17.     <input type=submit name=\"send\" value=\"Zarejestruj mnie\">
  18.     </form><br>";
  19.  
  20. } else {
  21. $user_login = $_POST['login'];
  22. $user_pass1 = $_POST['haslo1'];
  23. $user_pass2 = $_POST['haslo2'];
  24. $user_mail = $_POST['mail'];
  25. $user_gg = $_POST['gg'];
  26. if($_POST['token'] == $_SESSION['token'])
  27. { echo "Token przepisany poprawnie<br>";
  28.   if(!empty($user_login) && !empty($user_pass1) && !empty($user_pass2) && !empty($user_mail)){    //oraz czy uzupełniono wszystkie dane
  29.       if ($user_pass1 == $user_pass2) {
  30.        $check_query = mysql_query("SELECT * FROM users WHERE user_login='$user_login'");
  31.       if(mysql_num_rows($check_query)==1) { echo 'Uzytkownik juz istnieje.'; }
  32.       else{
  33.           $password = md5(md5($user_pass1));
  34.           $q = "INSERT INTO users (user_id, user_login, user_haslo, user_mail, user_gg, user_type) VALUES (0 , '$user_login' , '$password' , '$user_mail' , '$user_gg', '0')"; // zapisywanie rekordu do bazy
  35.           if (@mysql_query ($q)) {
  36.           echo "Konto załozono poprawnie.";
  37.           } else {
  38.           echo "Konto niemoze byc utworzone " . mysql_error() . ""; }
  39.           }
  40.       } else { echo 'Podane hasla nie zgadzaja sie'; }
  41.   }
  42.   else { echo "Nie uzupełniono wszystkich pól!!!"; }
  43. }
  44. else
  45. {
  46. echo"Błędnie przepisany token!<br>";
  47. }
  48. mysql_close(); //zamykanie połączenia z bazą
  49. }
  50. elseif ($register == "off")
  51. {
  52. echo "Rejestracja wyłączona!";
  53. }
  54. else
  55. {
  56. print 'Błąd konfiguracji!';
  57. }
  58.  
  59.  
  60. ?>
Dizzy
Czarnowisz oto błąd jaki mi wyswietla po wprowadzeniu poprawki przez ciebie:
  1. <?php
  2. Parse error: syntax error, unexpected T_ELSEIF in /home/Dizzy/domains/.**********.pl/public_html/strony/Rejestruj.php on line 50
  3. ?>
czarnowidz
  1. <img src="Grafika/podstrony/rejestracja.gif"><br><br>
  2. <?
  3. include 'Konfiguracja/Konfiguracja.php';
  4. if ($register == "on")
  5. {
  6. if (!isset($_POST['send'])) { // Sprawdzanie czy formularz zostal wyslany
  7. echo "<form action='index.php?show=Rejestruj' method=post>
  8.     <table>
  9.     <tr><td>Login:</td> <td><input type=\"text\" name=\"login\"> <font color=\"#FF0000\">*</font></td></tr>
  10.     <tr><td>Hasło:</td> <td><input type=\"password\" name=\"haslo1\"> <font color=\"#FF0000\">*</font></td></tr>
  11.     <tr><td>Powtórz Hasło:</td> <td><input type=\"password\" name=\"haslo2\"> <font color=\"#FF0000\">*</font></td></tr>
  12.     <tr><td>E-mail: <td><input type=\"text\" name=\"mail\"> <font color=\"#FF0000\">*</font></td></tr>
  13.     <tr><td>GG: <td><input type=\"text\" name=\"gg\"></td></tr>
  14.     <tr><td>Token:<td><img src='obrazek.php' width=\"120\" height=\"15\" alt=''></td></tr>
  15.     <tr><td><td><input type=\"text\" name=\"token\"> <font color=\"#FF0000\">*</font></td></tr>
  16.     </table><br><font color=\"#FF0000\">*</font> - Pola wymagane<br><br>
  17.     <input type=submit name=\"send\" value=\"Zarejestruj mnie\">
  18.     </form><br>";
  19.  
  20. } else {
  21. $user_login = $_POST['login'];
  22. $user_pass1 = $_POST['haslo1'];
  23. $user_pass2 = $_POST['haslo2'];
  24. $user_mail = $_POST['mail'];
  25. $user_gg = $_POST['gg'];
  26. if($_POST['token'] == $_SESSION['token'])
  27. { echo "Token przepisany poprawnie<br>";
  28.   if(!empty($user_login) && !empty($user_pass1) && !empty($user_pass2) && !empty($user_mail)){    //oraz czy uzupełniono wszystkie dane
  29.       if ($user_pass1 == $user_pass2) {
  30.        $check_query = mysql_query("SELECT * FROM users WHERE user_login='$user_login'");
  31.       if(mysql_num_rows($check_query)==1) { echo 'Uzytkownik juz istnieje.'; }
  32.       else{
  33.           $password = md5(md5($user_pass1));
  34.           $q = "INSERT INTO users (user_id, user_login, user_haslo, user_mail, user_gg, user_type) VALUES (0 , '$user_login' , '$password' , '$user_mail' , '$user_gg', '0')"; // zapisywanie rekordu do bazy
  35.           if (@mysql_query ($q)) {
  36.           echo "Konto załozono poprawnie.";
  37.           } else {
  38.           echo "Konto niemoze byc utworzone " . mysql_error() . ""; }
  39.           }
  40.       } else { echo 'Podane hasla nie zgadzaja sie'; }
  41.   }
  42.   else { echo "Nie uzupełniono wszystkich pól!!!"; }
  43. }
  44. else
  45. {
  46. echo"Błędnie przepisany token!<br>";
  47. }
  48. }
  49. mysql_close(); //zamykanie połączenia z bazą
  50. }
  51. else if ($register == "off")
  52. {
  53. echo "Rejestracja wyłączona!";
  54. }
  55. else
  56. {
  57. print 'Błąd konfiguracji!';
  58. }
  59.  
  60.  
  61. ?>
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.