<?php
session_start();
include('head1.php');
if(isset($_SESSION['user_id'])!="") {
header("Location: index.php");
exit();
}
//check if form is submitted
$con=mysqli_connect('localhost','root','','rating_system');
if (isset($_POST['login'])) {
$email = mysqli_real_escape_string($con, $_POST['email']);
$password = mysqli_real_escape_string($con, $_POST['password']);
$query="select * from tbl_users where email ='$email' and
password='$password'";
$result=mysqli_query($con,$query);
if ($row = mysqli_fetch_array($result)) {
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['username'] = $row['username'];
header("Location:afterlogin.php");
} else {
$errormsg = "Incorrect Email or Password!!!";
}
}
This code works well at localhost but not on the hosting website where the site is live.. i have to manually enter the afterlogin.php in browser to get to that page