Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP] Logowanie jako administrator
kona79
post 6.11.2012, 01:38:26
Post #1





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 6.11.2012

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


Witam, chciałbym dodać na stronie mały panel administratora. Staram się dodać warunek żeby po zalogowaniu się na admina wyświetlało mi się zupełnie inne okno: admin.php.
Warunek może być albo po ID=1 albo po loginie: admin. Bardzo proszę o pomoc, trochę się już z tym męczę

Kod
session_start();

require_once 'config.php';

$Message = "";


if (empty($_POST['login']) || empty($_POST['haslo']))
{
    $Message = "Login lub hasło jest puste!";
    header('location: index.php?Message='.$Message);
    exit;
}  


$wynik = mysql_query("select * from users where Login = '".$_POST['login']."'");

$ilosc_wynikow =  mysql_num_rows($wynik);

if ($ilosc_wynikow == 0)
{
    $Message = "Podany użytkownik nie istnieje!";
    header('location: index.php?Message='.$Message);        
}
else {

    while ($row = mysql_fetch_assoc($wynik)) {
  
        if ($row['Password'] == md5($_POST['haslo']))
        {
            $_SESSION['zalogowany'] = TRUE;
            $_SESSION['login'] = $row['Login'];
            $_SESSION['email'] = $row['Email'];
            
            $Message = "Zostałeś zalogowany!";
            header('location: index.php?Message='.$Message);
        } else {
            $Message = "Podane hasło jest błędne!";
            header('location: index.php?Message='.$Message);            
        }

    }
}
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 Wersja Lo-Fi Aktualny czas: 5.07.2025 - 17:21