0

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

Edited by rohit.k2903: n/a

4
Contributors
10
Replies
12
Views
5 Years
Discussion Span
Last Post by pzuurveen
0

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

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

Edited by ALFA-FOXTROT: n/a

0

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

Having problem on all header() function

0

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..

0

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?

Edited by simplypixie: n/a

0

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

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.