I have a page it is working fine but header function is not redirecting onto another page, it stuck. When I enter the url then its works..
Here is my code.. I changed my server recently
<?php
include "../dbconnect/cnn_mysql.php";
if($_POST)
{
$doneurl='';
if(array_key_exists('doneurl',$_POST))
$doneurl=$_POST["doneurl"];
else
$doneurl=$_SERVER['HTTP_REFERER'];
if(true)//$doneurl=="")
$doneurl="mykpojobs.php";
// $doneurl=str_replace('\r','',$doneurl);
/*$loginid=mysql_real_escape_string($_POST['txtloginid']);
$password=mysql_real_escape_string($_POST['txtpassword']);*/
$loginid=secure_form_data($_POST['txtloginid']);
$password=secure_form_data($_POST['txtpassword']);
//$result=mysql_query("select * from employers where email='$loginid' and pass='$password'");
$result=mysql_query("select * from employers where email='$loginid'");
if(mysql_num_rows($result)<1) //Not a valid login
{
header("Location: Login.php?errno=1.1&doneurl=$doneurl");
//echo $doneurl;
//var_dump($_POST);
exit();
}
else
{
$user=mysql_fetch_array($result);
$uemail = $user['email'];
$upass = $user['pass'];
if($uemail == $loginid && $upass == md5($password))
{
//if($user)
//{
//echo $upass;
if($user["status"]==1 && $user["verified"]==1) // Logged in successfully
{
@session_start();
$_SESSION['empid']=$user['id'];
$_SESSION['empemail']=$user['email'];
$_SESSION['empname']=$user['name'];
header("Location: $doneurl");
// it stuck after this line...
}
elseif($user["verified"]==0) // Loggin failed due to pending verification
{
header("Location: login.php?errno=1.2");
exit();
}
elseif($user["status"]==0) // Loggin failed due to account suspended
{
header("Location: login.php?errno=1.3");
exit();
}
else //Not logged in cause not known
{
//var_dump(mysql_num_rows($result));
header("Location: Login.php?errno=1.4");
exit();
}
}
else //Not logged in cause not known
{
//var_dump(mysql_num_rows($result));
header("Location: login.php?errno=1.1");
exit();
}
}
}
else
{
header("Location: index.php");
exit();
}
?>