Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> logowanie problem z autoryzacja użytkowników
nikestylex7
post
Post #1





Grupa: Zarejestrowani
Postów: 386
Pomógł: 7
Dołączył: 22.04.2010
Skąd: Ziemia

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


Witam napisałem dosyć niedawno system logowania z autoryzacja użytkowników dzisiaj mam problem gdyż znalazłem skrypt i dość różni się od mojego możecie mi powiedzieć co po kolei on robi ?
  1. <?PHP
  2. include "baza.php";
  3. function checkPass($user, $pass){
  4. $query = "SELECT COUNT(*) FROM user WHERE user='$user' ";
  5. $query .= "AND haslo='$pass'";
  6.  
  7. if(!$result = mysql_query($query)){
  8. return 1;
  9. }
  10.  
  11. if(!$row = @mysql_fetch_row($result)){
  12. return 1;
  13. }
  14. else{
  15. if($row[0] <> 1){
  16. return 2;
  17. }
  18. else{
  19. return 0;
  20. }
  21. }
  22. }
  23.  
  24. if(isSet($_SESSION['asd'])){
  25. header("Location: index.php");
  26. }
  27. else if(!isSet($_POST["pass"]) || !isSet($_POST["login"])){
  28. $_SESSION['komunikat'] = "Wpisz login i hasło:";
  29. include('index.php');
  30. }
  31. else{
  32. $nick = mysql_real_escape_string(htmlspecialchars(mb_strtolower($_POST["login"], "utf-8")));
  33. $haslo = md5(mysql_real_escape_string(htmlspecialchars($_POST['pass'])));
  34. $val = checkPass($nick, $haslo);
  35. if($val == 0){
  36. $_SESSION['asd'] = $nick;
  37. unSet($_SESSION['komunikat']);
  38. header("Location: index.php");
  39. }
  40. else if($val == 1){
  41. $_SESSION['komunikat'] = "Błąd serwera.";
  42. include('index.php');
  43. }
  44. else if($val == 2){
  45. $_SESSION['komunikat'] = "Nieprawidłowy login lub hasło.";
  46. include('index.php');
  47. }
  48. else{
  49. $_SESSION['komunikat'] = "Błąd!";
  50. include('index.php');
  51. }
  52. }
  53. ?>
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: 3.10.2025 - 11:42