Click to See Complete Forum and Search --> : header issue


Blizzard84
03-22-2008, 04:46 AM
if($_SESSION['LOGGEDIN']==1)
{
header("Location: ".$config_basedir."/closet/closet.php");
exit;
}
else
{
header("Location: ".$_SESSION['LAST_PAGE']."?error=1");
exit;
}

In my other files, each one stores it's url in $_SESSION['LAST_PAGE']

The problem is that whenever I have a incorrect login, the get variable error gets appended to the url again and again.
eg) www.asdf.com/index.php?error=1?error=1?error=1

Anybody know how to fix that problem? I don't see why it's getting appended.

Jick
03-22-2008, 05:22 AM
I think what you're going to want to do is search the $_SESSION['LAST_PAGE'] var for any instance of "?error=1". If it is found then don't append the "?error=1" part and just go to the page. If it isn't found then "?error=1" should be appended and then it should go there. So, something like this I would think:<?php
if($_SESSION['LOGGEDIN']==1)
{
header("Location: ".$config_basedir."/closet/closet.php");
exit;
}
else
{
if(stripos($_SESSION['LAST_PAGE'], '?error=1') >= 0) {
header("Location: ".$_SESSION['LAST_PAGE']);
exit;
}
else
{
header("Location: ".$_SESSION['LAST_PAGE']."?error=1");
exit;
}
}
?>Hope that helps. :)