IF and page redirection

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
giles
Forum Commoner
Posts: 34
Joined: Thu Sep 14, 2006 2:34 pm

IF and page redirection

Post by giles »

Hi,

I’m not sure if i’m just getting myself confused here! I want to build a simple redirection along the lines of :

Code: Select all

<?php
require_once "siteDefaultsPage.inc";
	
	if (!INTERACTION_TEST){
	// redirect to new URL
	}
?>
in order to control access to a page. I’m getting caught up with the headders being sent from the .inc file - however, I need the .inc file to set the variable INTERACTION_TEST. Can you help?
garry27
Forum Commoner
Posts: 90
Joined: Sat Oct 14, 2006 1:50 pm

Post by garry27 »

try this and replace with the page you want

Code: Select all

header ("Location: login.php");
User avatar
louie35
Forum Contributor
Posts: 144
Joined: Fri Jan 26, 2007 8:40 am
Location: Dublin
Contact:

Post by louie35 »

Code: Select all

if....(statement here){

    header("Location: your page");
    exit;

}//end if
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Be aware that you can't send any content before your header() call. Otherwise, javascript could easily redirect for you.
Post Reply