connect_errno!=0)
{
echo "Error: ".$polaczenie->connect_errno;
}
else
{
$login = $_POST['login'];
$haslo = $_POST['haslo'];
$login = htmlentities($login, ENT_QUOTES, "UTF-8");
if ($rezultat = @$polaczenie->query(
sprintf("SELECT * FROM uzytkownicy WHERE user='%s'",
mysqli_real_escape_string($polaczenie,$login))))
{
$ilu_userow = $rezultat->num_rows;
if($ilu_userow>0)
{
$wiersz = $rezultat->fetch_assoc();
if (password_verify($haslo, $wiersz['pass']))
{
$aa = $wiersz['perm'];
if($aa==1)
{
$_SESSION['zalogowany1'] = true;
$_SESSION['id'] = $wiersz['id'];
$_SESSION['user'] = $wiersz['user'];
$_SESSION['imie'] = $wiersz['imie'];
$_SESSION['nazwisko'] = $wiersz['nazwisko'];
$_SESSION['perm'] = $wiersz['perm'];
$_SESSION['email'] = $wiersz['email'];
$_SESSION['dnipremium'] = $wiersz['dnipremium'];
unset($_SESSION['blad']);
$rezultat->free_result();
header('Location: admin.php');
}
elseif($aa==2)
{
$_SESSION['zalogowany2'] = true;
$_SESSION['id'] = $wiersz['id'];
$_SESSION['user'] = $wiersz['user'];
$_SESSION['imie'] = $wiersz['imie'];
$_SESSION['nazwisko'] = $wiersz['nazwisko'];
$_SESSION['perm'] = $wiersz['perm'];
$_SESSION['email'] = $wiersz['email'];
$_SESSION['dnipremium'] = $wiersz['dnipremium'];
unset($_SESSION['blad']);
$rezultat->free_result();
header('Location: ucz.php');
}
else
{
$_SESSION['zalogowany3'] = true;
$_SESSION['id'] = $wiersz['id'];
$_SESSION['user'] = $wiersz['user'];
$_SESSION['imie'] = $wiersz['imie'];
$_SESSION['nazwisko'] = $wiersz['nazwisko'];
$_SESSION['perm'] = $wiersz['perm'];
$_SESSION['email'] = $wiersz['email'];
$_SESSION['dnipremium'] = $wiersz['dnipremium'];
unset($_SESSION['blad']);
$rezultat->free_result();
header('Location: klient.php');
}
}
else {
$_SESSION['blad'] = 'Nieprawidłowy login lub hasło!';
header('Location: login.php');
}
}
else {
$_SESSION['blad'] = 'Nieprawidłowy login lub hasło!';
header('Location: login.php');
}
}
$polaczenie->close();
}
?>