Can not redirect to the dashboard page. Data get echo but not redirected to the dashboard. Please help me to get out of this problem. Thanks in Advance.
if(isset($_POST['user_login'])){
$error=array();
$error2=array();
$username=htmlspecialchars($_REQUEST['username']);
if(empty($username)){
$error['username']="Username/User ID is required.";
}
$password=htmlspecialchars($_REQUEST['password']);
if(empty($password)){
$error['password']="Password is required.";
}
if(count($error)==0){
$q_seluser="select * from inst_user_registration where username= $username AND password=$password";
// echo "$q_seluser";
$q_selu_res=mysqli_query($q_seluser)or die(mysqli_error());
$login_num=mysqli_num_rows($q_selu_res);
//$login_num = mysqli_num_rows($q_seluser);
if($login_num==1){
session_start();
$login_row=mysqli_fetch_array($q_selu_res,MYSQLI_ASSOC);
$_SESSION['uid']=$login_row['uid'];
echo'<script>window.location="user-dashboard.php";</script>';
}
else{
$error2[]="Either Username and/or Password wrong.";
}
}
}
?>
Thanks for the help. Login details get echo but cannot redirect to the next page after login. It shows a blank page. I am a beginner to php and cannot get this error.