Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Logowanie
Mastroeni7
post
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 22.02.2011

Ostrzeżenie: (0%)
-----


Chcę, aby mój skrypt przekierowywał admina na inną stronę, oraz użytkownika na inną. Problemem jest to, że co nie wpiszę przechodzi mi tylko do 'user.php' Może powiecie co jest nie tak ? Na początku jeszcze wyskakuje mi błąd Notice: Undefined index: login in /home/***//logowanie.php on line 10
  1. <?php
  2.  
  3. include ('db.php');
  4. function clean($value) {
  5. if(get_magic_quotes_gpc()) $value = stripslashes($value);
  6. return trim(mysql_real_escape_string($value));
  7. }
  8.  
  9. if($_POST['login'] && $_POST['username'] && $_POST['password']) {
  10. $username = clean($_POST['username']);
  11. $password = md5($_POST['password']);
  12.  
  13. $isAdmin = mysql_query("SELECT count(*) FROM users WHERE user_name = '$username' AND user_type = '1'");
  14. if(mysql_num_rows($isAdmin) == 1) {
  15. header("Location: admin.php");
  16. }
  17.  
  18. $result = mysql_query("SELECT count(*) FROM users WHERE user_name = '$username' AND user_password = '$password' and user_type='2'");
  19. if(mysql_num_rows($result) == 1) {
  20. $_SESSION['username'] = $username;
  21. header("Location: user.php");
  22. } else {
  23. header("Location: opps.php");
  24. }
  25. }
  26.  
  27.  
  28. ?>
  29. formularz w htmlu

user_type = 1, mam w mysql dla admina, user_type = 2, dla użytkownika
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 Aktualny czas: 20.08.2025 - 19:59