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
 
Start new topic
Odpowiedzi
nikestylex7
post
Post #2





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

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


<?PHP
include "baza.php";
function checkPass($user, $haslo, $aktywacja1){
$query = "SELECT user, haslo, aktywacja FROM user WHERE user='$user' AND haslo='$haslo' LIMIT 1";

if(!$result = mysql_query($query)){
@mysql_close();
return 1;
}elseif(!$row = @mysql_fetch_row($result)){
@mysql_close();
return 1;
}
else{
if($row[0] <> 1){
@mysql_close();
return 2;
}
else if($row[2] <> 1){
@mysql_close();
return 3;
}
else{
@mysql_close();
return 0;
}
}
}

session_start();
if(isSet($_SESSION['mohergame'])){
header("Location: index.php");
}
else if(!isSet($_POST["haslo"]) || !isSet($_POST["user"])){
$_SESSION['komunikat'] = "Wpisz login i hasło:";
include('index.php');
}
else{
$nick = mysql_real_escape_string(htmlspecialchars(mb_strtolower($_POST["user"], "utf-8")));
$haslo = md5(mysql_real_escape_string(htmlspecialchars($_POST['haslo'])));
$aktywacja1 = $_POST["aktywacja"];
$val = checkPass($nick, $haslo, $aktywacja1);
if($val == 0){
$_SESSION['mohergame'] = $nick;
unSet($_SESSION['komunikat']);
header("Location: index.php");
}
else if($val == 1){
$_SESSION['komunikat'] = "Błąd serwera.";
include('index.php');
}
else if($val == 2){
$_SESSION['komunikat'] = "Nieprawidłowy login lub hasło.";
include('index.php');
}
else if($val == 3){
$_SESSION['komunikat'] = "Nie aktywowałeś konta. Możesz to zrobić za pomocą e-maila, którego Ci wysłaliśmy na podany przez Ciebie e-mail podczas rejestracji. Możesz także wysłać go jeszcze raz przechodząc <a href='kod_aktywacyjny.php'>tutaj</a>.";
include('index.php');
}
else{
$_SESSION['komunikat'] = "Błąd!";
include('index.php');
}
}
?>

Poprawiłem trochę kod i dalej nic wyskakuje cały czas wpisz login i haslo nie patrząc czy dobre czy złe
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: 8.10.2025 - 20:15