Advertisement
Guest User

e14php

a guest
Jan 31st, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if (isset($_SESSION['login'])) {
  4.     if ($_SESSION['admin'] == true) {
  5.         header("Location: doceloweadmin.php");  
  6.     }
  7.     header("Location: docelowe.php");
  8. }
  9.  
  10. if (empty($_POST['login']) || empty($_POST['password'])) {
  11.     $_SESSION['blad'] = "Uzupelnij wszystkie pola";
  12.     header("Location: index.php");
  13. }
  14.  
  15. require_once "polaczenie.php";
  16. $polaczenie = new mysqli($host, $db_user, $db_pass, $db_name);
  17.  
  18. if ($polaczenie->connect_errno != 0) {
  19.     echo "Error: ".$polaczenie->connect_errno;
  20. } else {
  21.     $login = $_POST['login'];
  22.     $password = $_POST['password'];
  23.     $sql = "SELECT * FROM uzytkownicy WHERE user='$login' AND pass='$password'";
  24.    
  25.     if ($rezultat = $polaczenie->query($sql)) {
  26.         $ilu_userow = $rezultat->num_rows;
  27.         if ($ilu_userow > 0) {
  28.             $wiersz = $rezultat->fetch_assoc();
  29.             $_SESSION['login']=$wiersz['user'];
  30.             $_SESSION['admin']=$wiersz['admin'];
  31.            
  32.             $rezultat->close();            
  33.             header("Location: docelowe.php");
  34.         }
  35.     }
  36.     $_SESSION['blad'] = "Podano zly login/haslo";
  37.     header("Location: index.php");
  38. }
  39. $polaczenie->close();
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement