Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [[PHP]Dziwny błąd w systemie logowania, blokada wejścia administracji., proszę o pomoc w skrypcie
sebap123
post
Post #1





Grupa: Zarejestrowani
Postów: 253
Pomógł: 1
Dołączył: 26.08.2009
Skąd: Szczecin

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


Witam
Napisałem prosty skrypt logowania na stronę. Można logować się jako admin i user. Jak loguje sie jako user wszystko jest ok. Jak jako admin to nie chce mi działać. Może ktoś powiedzieć co jest nie tak w tym systemie?
kod:
walidate_l.php
  1. <?php
  2. require_once "includes/connect.php";
  3. if (isset ($_POST['submit']))
  4. {
  5. $login = $_POST['login'];
  6. $query = mysql_query("SELECT * FROM Uzytkownicy WHERE login = '$login' ");
  7. $fetch = mysql_fetch_array($query);
  8. $usr = $getlist3['login'];
  9. if ( $fetch ) // jesli user zostanie znaleziony w bazie
  10. {
  11. if ( md5( $_POST['password'] ) == $fetch['haslo'] ) // jesli haslo sie zgadza
  12. {
  13. //session_start();
  14. if ($fetch['status'] == 0)
  15. {
  16. print "Twoje konto nie jest aktywne";
  17. }
  18. if ($fetch['status'] == 1)
  19. {
  20. //session_start();
  21. $_SESSION['login'] = "$usr";
  22. print 'logowanie normalne zakonczone sukcesem<br>';
  23. print 'Zalogowany';
  24. print '<a href="sender.php">Klik</a>';
  25. }
  26. if ($fetch['status'] >1)
  27. {
  28. //session_start();
  29. $_SESSION['login'] = "$usr";
  30. print 'logowanie specjalne zakonczone sukcesem<br>';
  31. print "Zalogowany<br>";
  32. print '<a href="admin.php">link</a><br>';
  33. }
  34. }
  35. else
  36. {
  37. print 'Przykro mi, ale podane haslo jest bledne';
  38. }
  39. }
  40. else
  41. {
  42. print 'Podany uzytkownik nie istnieje w bazie danych';
  43. }
  44. }
  45. else
  46. {
  47. print "Blad";
  48. }
  49. ?>


admin.php
  1. <?php
  2. include "includes/base.php";
  3. if ($status >1)
  4. {
  5. //if (isset ($_SESSION['login']))
  6. ?>
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  8. <html xmlns="http://www.w3.org/1999/xhtml">
  9. <head>
  10. <meta http-equiv="Content-Type" content="text/html; charset=windows-1250" />
  11. <title>Untitled Document</title>
  12.  
  13.  
  14. </head>
  15.  
  16.  
  17.  
  18. <body>
  19. <center>
  20. <!--TOP-->
  21. ...
  22. <!--KONIEC STOPKA-->
  23. </center>
  24.  
  25. <br />
  26.  
  27. </body>
  28. </html>
  29.  
  30. <?
  31. }
  32. if ($error == 1){
  33. print "nie ma usera";
  34. }
  35. else
  36. {
  37. $adres = 'http://pk.xyx.pl'.'/?er=1';
  38. Header('HTTP/1.1 301 Moved Permanently');
  39. Header('Location: '.$adres);
  40. }
  41. ?>


base.php
  1. <?
  2. require_once "includes/connect.php";
  3. if (isset ($_SESSION['login']))
  4. {
  5. //$id =
  6. $login = htmlspecialchars ($user);
  7. $query = mysql_query("SELECT * FROM Uzytkownicy WHERE login = '$login' ");
  8. $fetch = mysql_fetch_array($query);
  9. $getlist="Select * from Uzytkownicy WHERE login = '$login'";
  10. $getlist2=mysql_query($getlist) or die ("Could not get list");
  11. $getlist3=mysql_fetch_array($getlist2);
  12. if ( $fetch )
  13. {
  14. $imie = $fetch['imie'];
  15. $status = $fetch['status'];
  16. }}
  17. else
  18. {
  19. $error = 1;
  20. }
  21. ?>


Będę bardzo wdzięczny za pomoc.
Powód edycji: [erix]: otwieram
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: 22.08.2025 - 12:34