I\'m learning PHP and I have made a simple login script but the problem is that it only redirects me to a blank page. It\'s meant to redirect to index.php if user credentials ar
First of all the name of your submit button is "submit". And you are checking if the "login" is post or not.
if(isset($_POST['login']))
{
it should have been:
if(isset($_POST['submit']))
{
You have written :
if($user || $password != NULL)
{
it should have been:
if($user != NULL || $password != NULL)
{
You have used mysqli and mysql command which is not a good practice
$result=mysqli_query($sql);
$row=mysql_fetch_array($result);
Instead of
if($row['user'] == $user && $row['password'] == $password)
{
//this code again check for condition which is already checked in the sql statement
it is better practice to write :
if($row->num_rows==1)
{
in index.php you have written
if(!isset($_SESSION["loggedIn"])){
it should have been
if(!isset($_SESSION["loggedin"])){
since you have stored the lowercase index while storing into session.