Untitled

                Never    
PHP
       
<!DOCTYPE html>
<html>
	<head>
		<title>Logowanie</title>
		<link rel="stylesheet" href="style/style.css">
	</head>
	<body>
		<div class="logowanie">
			<h3>Logowanie</h3>
			<form method="POST">
				<input type="text" name="username" value="" placeholder="Login">
				<input type="password" name="password" value="" placeholder="Hasło">
				<input type="submit" value="Zaloguj">
			</form>
<?php
session_start();

$_SESSION['logged'] = false;

if (isset($_POST['username']))
{
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    $query = "SELECT * FROM users WHERE users.username = '$username' AND users.password = '$password';";
    
	require('config.php');
	$link = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);

    $result = $link->query($query);

    if ($result->num_rows == 1)
    {
        $_SESSION['logged'] = true;
        $_SESSION['username'] = $username;
		$_SESSION['id'] = $row['id'];
		$_SESSION['admin'] = $row['admin'];
        header('Location: index.php');
    }
	else {
		echo "Nieprawidłowa nazwa użytkownika lub hasło.</br>";
	}
}
?>
			Nie masz jeszcze konta? <a href='register.php'>Zarejestruj się</a>
		</div>
	</body>
</html>