Jump to content

Php Order Of Opperations


Recommended Posts

I've written some functions for my forum to make it easier to handle users. I thought it was working fine until I checked the database and found that even if my script called to redirect an unlogged in user, all the other scripts in the code were ran.The function-

function checkUserStrict() //Checks if the visitor is logged in{	if(!isset($_SESSION["username"]))	{		$x = checkUser();		if($x == 0)			header( "Location: loginforms.php" );	}}

The page that calls the function-

	include("includes/universalfunctions.php");	checkUserStrict();	header( "Location: index.php" );

The function works fine, it will redirect me if I am not logged in. But I tested it by adding another redirect after the function. I immediately go to the index page when accessing this page. How do I tell the code to wait until it finishes the check.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...