Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if (isset($_SESSION['login'])) {
- if ($_SESSION['admin'] == true) {
- header("Location: doceloweadmin.php");
- }
- header("Location: docelowe.php");
- }
- if (empty($_POST['login']) || empty($_POST['password'])) {
- $_SESSION['blad'] = "Uzupelnij wszystkie pola";
- header("Location: index.php");
- }
- require_once "polaczenie.php";
- $polaczenie = new mysqli($host, $db_user, $db_pass, $db_name);
- if ($polaczenie->connect_errno != 0) {
- echo "Error: ".$polaczenie->connect_errno;
- } else {
- $login = $_POST['login'];
- $password = $_POST['password'];
- $sql = "SELECT * FROM uzytkownicy WHERE user='$login' AND pass='$password'";
- if ($rezultat = $polaczenie->query($sql)) {
- $ilu_userow = $rezultat->num_rows;
- if ($ilu_userow > 0) {
- $wiersz = $rezultat->fetch_assoc();
- $_SESSION['login']=$wiersz['user'];
- $_SESSION['admin']=$wiersz['admin'];
- $rezultat->close();
- header("Location: docelowe.php");
- }
- }
- $_SESSION['blad'] = "Podano zly login/haslo";
- header("Location: index.php");
- }
- $polaczenie->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement