PHP header function not working (urgent)
Moderator: General Moderators
PHP header function not working (urgent)
my header function is not working...it doesnt gives any error but doesn't redirects either..any clue why?
-
andylyon87
- Forum Contributor
- Posts: 168
- Joined: Sat Jan 31, 2004 5:31 am
- Location: Dundee
Here is the code
Code: Select all
session_start();
if(!isset($search))
$search=0;
if(!isset($_SESSION['auth']))
$_SESSION['auth']=0;
if(!isset($_SESSION['admin']))
$_SESSION['admin']=0;
if(!isset($_SESSION['member_type']))
$_SESSION['member_type']=4;
if(!isset($_SESSION['art_upload']))
$_SESSION['art_upload']=0;
if(!isset($_SESSION['main_id_']))
$_SESSION['main_id_']="";
if($_SESSION['admin']==0||$_SESSION['auth']==0)
header("Location : ../../index.php");- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
i have tried that
i have tried replacing it with a full uri i.e
but this didnt worked either.
Code: Select all
header("Location : http://www.sdf.com/dmo/ioc/index.php");it will only redirect if
Make sure these variables are actually what you expect...dont presume they are, echo them out
Code: Select all
$_SESSION['admin']==0||$_SESSION['auth']==0i have done that too...and as far as i know if you echo something before header() function it doesn't work... but when i did that
this seems to stop the page from loading...that means header function has not been excuted successfully
Code: Select all
header("location : http://www.yahoo.com") or die();yes, i know the header function wont work if you echo before you call it, that doesn't matter, we are taking a step back to determine the variables are what you think they arelocalhost wrote:i have done that too...and as far as i know if you echo something before header() function it doesn't work... but when i did that
add this after your session_start() call, and post the result
Code: Select all
echo $_SESSION['admin'];
echo $_SESSION['auth']before the header call add...
See if the string outputs
Code: Select all
echo "i got to here";got it!!
remove the space before the semi-colon
this
becomes
remove the space before the semi-colon
this
Code: Select all
header("Location : ../../index.php");Code: Select all
header("Location: ../../index.php");