This is my login page and this does not verify that user login is true or false after inserting any password or username it redirects the user to the login page again. Header location is also not working. I am new in php, so I am not sure what the issue is.
<?php
session_start();
$username = $password = $userError = $passError = '';
if(isset($_POST['sub'])){
$username = $_POST['username'];
$password = $_POST['password'];
if($username === '9155499248' && $password === 'Ben 10'){
$_SESSION['login'] = true;
header('LOCATION:congratulation.php');
die();
}
if($username !== '9155499248')
$userError = 'Invalid Username';
if($password !== 'Ben 10')
$passError = 'Invalid Password';
}
echo "<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='content-type' content='text/html;charset=utf-8' />
<title>Login</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css"/>
<script src="js/prefixfree.min.js"></script>
</head>
<body>
<div class="login">
<h1><b>Login</b></h1>
<form name='input' action='{$_SERVER['PHP_SELF']}' method='post'>
<label for='username'></label><input type='text' value='$username' id='username' name='username' />
<div class='error'>$userError</div>
<label for='password'></label><input type='password' value='$password' id='password' name='password' />
<div class='error'>$passError</div>
<button type="submit" class="btn btn-primary btn-block btn-large" name="submit">Let me in.</button>
</form>
</div>
<script src="js/index.js"></script>
</body>
</html>