Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z logowaniem.
hzl_91
post 1.01.2007, 19:02:23
Post #1





Grupa: Zarejestrowani
Postów: 70
Pomógł: 0
Dołączył: 28.03.2006
Skąd: Częstochowa

Ostrzeżenie: (10%)
X----


Siema. Dzisiaj chciałem sobie zrobić logowanie. Działa, ale nie trzyma sesji. Nie wiem czemu.

Oto kod:
  1. <?php
  2.  
  3. function login_ok() {
  4. global $inf, $stat;
  5.  
  6. $user = $_SESSION['user'];
  7. $pass = $_SESSION['pass'];
  8.  
  9. $query = "SELECT * FROM swipi_users WHERE users_login ='$user' AND users_password ='$pass';";
  10. $result = mysql_query($query);
  11. $yes = mysql_num_rows($result);
  12. if($yes==0) { $ret=FALSE; } else { $ret=TRUE; }return $ret;
  13. }
  14.  
  15. function user_info() {
  16. $user = $_SESSION['user'];
  17. $pass = $_SESSION['pass'];
  18.  
  19. $query = mysql_query("SELECT * FROM swipi_users WHERE users_login ='$user' AND users_password ='$pass';");
  20. $r = mysql_fetch_array($query);
  21.  
  22. $inf[1] = $r['users_id'];
  23. $inf[2] = $r['users_login'];
  24. $inf[3] = $r['users_password'];
  25. $inf[4] = $r['users_email'];
  26. return $inf;
  27. }
  28.  
  29. ?>


  1. <?php
  2.  
  3. switch($load) {
  4. default :
  5. echo'<form method="POST" action="index.php?mode=login&load=log_me">
  6. <p><input type="text" name="user" size="20" value="login"></p>
  7. <p><input type="password" name="pass" size="20" value="pass"><input type="submit" value="Zaloguj sie" name="B1"></p>
  8. <a href="logowanie.php?co=dodaj">Rejestracja</a>
  9. </form>';
  10. break;
  11.  
  12. case 'log_me':
  13. //dodaj sesje
  14. $_SESSION['user']=$_POST[user];
  15. $_SESSION['pass']=md5($_POST[pass]);
  16.  
  17. //Loguje do systemu
  18. if(login_ok()) {
  19. $stat = user_info();
  20. header("Location: massange.php?value=true&top=LogIN&text=You logget&url=index.php");
  21. } else {
  22. header("Location: massange.php?value=false&top=Error Login&text=Please&url=index.php?mode=login");
  23. }
  24. break;
  25. }
  26.  
  27. ?>


Nie wiem czemu nie działa.


--------------------
Projektowanie stron internetowych | Need For Speed NFS
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: 14.08.2025 - 14:35