Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP][MySQL] Logowanie, potrzebuję pomocy ze skryptem...
-Śledź-
post
Post #1





Goście







Zrobiłem taki skrypt i mogę zalogować się tylko na usera który jest na pierwszym miejscu w bazie danych... i nie wiem co mam robić...

  1. <?
  2. require_once "config.php";
  3.  
  4. $sql="SELECT * FROM user";
  5.  
  6. $wynik=mysql_query($sql);
  7. $linia=mysql_fetch_array($wynik);
  8.  
  9.  
  10. if(!$haslo) { // jeżeli nie zostało wpisane hasło wczytujemy formularz do jego wpisania
  11.  
  12. print "<center>To jest prywatna część strony, wymagane jest hasło:</center><br>";
  13. print "<center><form method=post action=index.php></center>";
  14. print "<center><input type=text name=login></center><br>";
  15. print "<center><input type=password name=haslo></center><br>";
  16. print "<center><input type=submit name=loguj value=loguj></center></form>";
  17.  
  18. } else if($action=='wyloguj') { // skrypt odpowiedzialny za wylogowanie z systemu
  19.  
  20. print "<center>Zostałeś pomyślnie wylogowany</center>";
  21. print "<center><form method=post action=index.php></center>";
  22. print "<center><input type=text name=login></center><br>";
  23. print "<center><input type=password name=haslo></center><br>";
  24. print "<center><input type=submit name=loguj value=loguj></center></form>";
  25.  
  26. } else if($haslo==$linia[pass] && $login==$linia[login]) { // sprawdza czy hasło jest poprawne
  27.  
  28. session_register ("haslo");
  29.  
  30. echo 'Jesteś zalogowany jako: '.$linia[nick].'<br>';
  31. echo '<a href="index.php?action=wyloguj">Wyloguj</a><br>';
  32.  
  33. } else { // wyświetla komunikat jeżeli wpisane hasło jest błędne
  34.  
  35. print "<center>Błędne hasło!!!</center>";
  36. print "<center><form method=post action=index.php></center>";
  37. print "<center><input type=text name=login></center><br>";
  38. print "<center><input type=password name=haslo></center><br>";
  39. print "<center><input type=submit name=loguj value=loguj></center></form>";
  40. }
  41. ?>
Go to the top of the page
+Quote Post
Lion_87
post
Post #2





Grupa: Zarejestrowani
Postów: 850
Pomógł: 120
Dołączył: 15.02.2007
Skąd: Łódź

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


musisz zmienic zapytanie do bazy bo to jest złe
Kod
$sql="SELECT * FROM user";


musisz zapytać czy istnieje taki użytkownik i czy hasło jakie podano jest takie samo jak hasło użytkownika o takim nicku

cos w stylu

Kod
$sql="SELECT * FROM user where login=$login and haslo=$haslo";


Ten post edytował Lion_87 15.01.2008, 21:22:40
Go to the top of the page
+Quote Post

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: 23.08.2025 - 04:57