Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if ((!isset($_POST['username'])) || (!isset($_POST['password'])))
- {
- header('Location: index.php');
- exit();
- }
- require_once "connect.php";
- $connect = @new mysqli($DB_host, $DB_user, $DB_password, $DB_name);
- if ($connect->connect_errno!=0)
- {
- echo "Error: ".$connect->connect_errno;
- }
- else
- {
- $login = $_POST['username'];
- $haslo = $_POST['password'];
- $login = htmlentities($login, ENT_QUOTES, "UTF-8");
- if ($rezultat = @$connect->query(
- sprintf("SELECT * FROM users WHERE username='%s'",
- mysqli_real_escape_string($connect,$login))))
- {
- $ilu_userow = $rezultat->num_rows;
- if($ilu_userow>0)
- {
- $wiersz = $rezultat->fetch_assoc();
- if (password_verify($haslo, $wiersz['password']))
- {
- $_SESSION['zalogowany'] = true;
- $_SESSION['id'] = $wiersz['id'];
- $_SESSION['username'] = $wiersz['username'];
- $_SESSION['auth'] = $wiersz['auth'];
- $_SESSION['points'] = $wiersz['points'];
- $_SESSION['sukces'] ='<div class="sukces"><i class="fa fa-times"></i> Zalogowano pomyślnie :)</div>';
- unset($_SESSION['blad']);
- $rezultat->free_result();
- header('Location: index.php');
- }
- else
- {
- unset($_SESSION['sukces']);
- $_SESSION['blad'] ='<div class="blad"><i class="fa fa-times"></i> Błędne dane :(</div>';
- header('Location: index.php');
- }
- } else {
- unset($_SESSION['sukces']);
- $_SESSION['blad'] ='<div class="blad"><i class="fa fa-times"></i> Błędne dane :(</div>';
- header('Location: index.php');
- }
- }
- $connect->close();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement