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();
	}	
?>

Which header location redirect isn't working (you have a few), or is it all of them?

case sensitive header("Location: Login.php?errno=1.4"); Login or login

on windows machines no issues but on linux you may have...

Which header location redirect isn't working (you have a few), or is it all of them?

Having problem on all header() function

As per Alfa-Fostrot's reply, you firstly need to change Login.php in the redirect url to login.php.

As per Alfa-Fostrot's reply, you firstly need to change Login.php in the redirect url to login.php.

I changed, still have problem.. not redirecting..

You say it gets stuck after this line:

header("Location: $doneurl");

That would suggest to me that the location in your $doneurl variable is incorrect.

Have you tried echoing out the variable above the header redirect (comment out the redirect and exit whilst you do this testing) to ensure it is a valid url?

just a thought:

do you have a 'headers already send' error
with you error messages turned off?

test by using by using a echo-statement at the start of your script

just a thought:

do you have a 'headers already send' error
with you error messages turned off?

test by using by using a echo-statement at the start of your script

I have no headers already send error.
I tested.. its working fine. Actually, its not redirecting.. Using javascript its working.. But I have to use header() function coz using javascript it stuck for a fraction of a second, which looks awkward.

DId you echo out the $doneurl as I suggested?

I suggest using
firebug's netpannel to trie and figure out the problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.