Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Logowanie nie działa
Domin
post
Post #1





Grupa: Zarejestrowani
Postów: 136
Pomógł: 0
Dołączył: 17.11.2004
Skąd: Warszawa

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


Może ktoś mi pomóc, bo nie wiem dlaczego mi to nie działa...

function.php
  1. #definicje stalych
  2. define("SESID", SESSION_NAME() . "=" . SESSION_ID());
  3.  
  4.  
  5. function login($login, $passwd)
  6. {
  7. $query = mysql_query('SELECT id_user FROM users WHERE username="'.$login.'" && password="'.$passwd.'"');
  8. $result = mysql_query($query);
  9. $row = mysql_fetch_array($result);
  10. if ( $row = 1 )
  11. {
  12. $_SESSION["USER_AUTH"] = True;
  13. $_SESSION["USER_LOGIN"] = $_POST["login"];
  14. return True;
  15. }
  16. $login = htmlentities($login);
  17. return False;
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  echo '<table width="350" align="center"><tr><td>
  24.  <div class="login">
  25. <div class="login-form">
  26. <img src="images/login/login.gif" alt="Login" />
  27. <form name="login" action="index.php" method="post">
  28. <input type="hidden" name="option" value="login" />
  29. <input type="hidden" name="<?=SESSION_NAME()?>" value="<?=SESSION_ID()?>">
  30. <div class="form-block">
  31. <div class="inputlabel">Użytkownik</div>
  32. <div><input type="text" name="login" class="loginbox" value="<?=$_POST["login"]?>" /></div>
  33. <div class="inputlabel">Hasło</div>
  34. <div><input type="password" name="passwd" class="loginbox" /></div>
  35. <div align="left"><input type="submit" name="loguj" value="Zaloguj" class="button"/></div>
  36. </div>
  37. </form>
  38. </div>
  39. <div class="login-text">
  40. <div class="ctr"><img src="images/login/security.png" width="64" height="64" alt="security" /></div>
  41. Witaj w Intranecie!<br><br>
  42. Wpisz uważnie swój login i hasło, aby <br>uzyskać dostęp do panelu administracyjnego.
  43. </div>
  44. <div class="clr">&nbsp;</div>
  45. </div></td></tr></table>';
  46. }
  47.  
  48. # sprawdz czy zalogowany
  49. function auth()
  50. {
  51. return ($_SESSION["USER_AUTH"] == True);
  52. }
  53.  
  54. # wyloguj user-a
  55. function logout()
  56. {
  57. $_SESSION["USER_AUTH"] = False;
  58. $_SESSION["USER_LOGIN"] = Null;
  59. }





session.php
  1. <?php
  2.  
  3. # logowanie, wylogowanie itp
  4. switch ($option)
  5. {
  6. case "login" :
  7. $login = htmlentities(substr($_POST["login"], 0, 255));
  8. $passwd = htmlentities(substr($_POST["passwd"], 0, 255));
  9. login($login, md5($password));
  10. break;
  11.  
  12. case "logout" : logout();
  13. break;
  14. }
  15. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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: 14.09.2025 - 20:13