I put a validation check on my page so that it is only accessible via login, but the problem is that after logged in header redirects it to to the log in page meaning it fails the log in check. I am typing the correct credentials and i have started the sessions, but still no idea what is wrong. I really appreciate your help.
login.php
<?php
session_start();
include("dbConnection.php");
if(isset($_POST['username']) && isset($_POST['pass']))
{
$username = $_POST['username'];
$password = $_POST['pass'];
$query = mysql_query(" SELECT * FROM login WHERE username='$username' and password='$password'");
if($username == 'alex' && $password == 'lion'){
header('Location: alex.php' );
exit();
}
?>
<form class="login100-form validate-form" method="POST">
<span class="login100-form-title p-b-37">
Sign In
</span>
<div class="wrap-input100 validate-input m-b-20" data-validate="Enter username or email">
<input class="input100" type="text" name="username" placeholder="username or email">
<span class="focus-input100"></span>
</div>
<div class="wrap-input100 validate-input m-b-25" data-validate = "Enter password">
<input class="input100" type="password" name="pass" placeholder="password">
<span class="focus-input100"></span>
</div>
<div class="container-login100-form-btn">
<button class="login100-form-btn">
Sign In
</button>
<?php if(isset($_GET['error'])==true){
echo'<strong><p align ="center" id="wrong" color ="red">Wrong Username or Password !!</p></strong>';
}?>
</div>
alex.php
<?php
ob_start();
include("dbConnection.php");
if(!isset($_SESSION['username'])){
header("location:login.php");
}
?>