Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if ((!isset($_POST['login'])) || (!isset($_POST['haslo'])))
- {
- header('Location: index.php');
- exit();
- }
- require_once "connect.php";
- $polaczenie = new mysqli($host, $db_user, $db_password, $db_name);
- if ($polaczenie->connect_errno!=0)
- {
- echo "Error: ".$polaczenie->connect_errno;
- }
- else
- {
- $login = $_POST['login'];
- $haslo = $_POST['haslo'];
- $haslo_hash = hash("sha256", $_POST['haslo']);
- $login = htmlentities($login, ENT_QUOTES, "UTF-8");
- $haslo = htmlentities($haslo_hash, ENT_QUOTES, "UTF-8");
- echo mysql_error();
- if ($rezultat = @$polaczenie->query(
- sprintf("SELECT * FROM uzytkownicy WHERE user='%s' AND pass='%s'",
- mysqli_real_escape_string($polaczenie,$login),
- mysqli_real_escape_string($polaczenie,$haslo_hash))))
- {
- echo mysql_error();
- $ilu_userow = $rezultat->num_rows;
- if($ilu_userow>0)
- {
- include"refresh.php";
- unset($_SESSION['blad']);
- $rezultat->free_result();
- header('Location: main.php');
- echo mysql_error();
- }
- else
- {
- $_SESSION['blad'] = ' Nieprawidłowy login lub hasło! ';
- header('Location: index.php');
- }
- }
- $polaczenie->close();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement