Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Czemu logowanie mi nie działa?
dre
post 13.08.2007, 12:26:15
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 13.08.2007

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


Napisałem coś takiego:

  1. <?php
  2. include("config.php");
  3.  
  4. switch ($_GET['load']) {
  5. default:
  6. echo '<html>
  7.  
  8. <head>
  9. <meta http-equiv="Content-Language" content="pl">
  10. <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
  11. <title>Nowa strona 1</title>
  12. </head>
  13.  
  14. <body>
  15.  
  16. <div align="center">
  17. <form method="POST" action="admin.php?load=login">
  18. <table border="0" width="200" cellspacing="0" cellpadding="0" bgcolor="#C0C0C0">
  19. <tr>
  20. <td>
  21. <p style="margin-left: 4px"><font face="Arial" size="1">Login:</font></p></td>
  22. <td><input type="text" name="user" size="20"></td>
  23. </tr>
  24. <tr>
  25. <td><p style="margin-left: 4px"><font face="Arial" size="1">Hasło:</font></p></td>
  26. <td><input type="password" name="pass" size="20"></td>
  27. </tr>
  28. <tr>
  29. <td colspan="2" align="center"><p style="margin-left: 4px">
  30. <input type="submit" value="Zaloguj" name="a1"></p></td>
  31. </tr>
  32. </table>
  33. </form>
  34. </div>
  35.  
  36. </body>
  37.  
  38. </html>';
  39. break;
  40.  
  41. //Logowanie
  42. case 'login':
  43. $users = $_POST['user'];
  44. $passs = md5($_POST['pass']);
  45. $_SESSION['user'] = $users;
  46. $_SESSION['pass'] = $passs;
  47. header("Location: admin.php?modul=index");
  48. break;
  49. }
  50.  
  51. function login_ok() 
  52. {
  53. $user = $_SESSION['user'];
  54. $pass = $_SESSION['pass'];
  55.  
  56. $query = mysql_query("SELECT * FROM users WHERE users_login ='$user' AND users_password ='$pass';");
  57. $login_ok = mysql_num_rows($query);
  58. if($login_ok==0) { $ret=FALSE; } else { $ret=TRUE; }return $ret;
  59. }
  60.  
  61. switch ($_GET['modul']) {
  62. case 'index':
  63. if( login_ok() ) {
  64. echo 'ok';
  65. }
  66. else
  67. {
  68. echo 'nie';
  69. }
  70. break;
  71. }
  72.  
  73. ?>


Co jest źle, że nie działa mi logowanie? TZN. Nie wiem czy sesji nie zapamiętuje, czy co, bo zawsze funkcja login_ok() zwraca else.

Ten post edytował dre 13.08.2007, 12:28:34
Go to the top of the page
+Quote Post

Posty w temacie


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: 18.07.2025 - 02:14