Page 1 of 1
[SOLVED] undefined indexes
Posted: Sun Mar 06, 2005 7:38 pm
by pleigh
hi there...got a problem here....i have this error, undefined indexes...refers to the session keys that the script is calling...this happens when i access, for example, the index page, without logging in....the page requires to validate the session keys i've defined.....now, my idea is that users are limited in accessing the page by redirecting them to the login page.....i have done the following code
Code: Select all
if ($_SESSIONї'key'] == NULL)
{
header('location: login.php');
}
else
{
session_start();
require_once('mysql_connect.php');
}
it worked but when i tried to login, it redirects me to the login page again, though, the usename and password is correct
Posted: Sun Mar 06, 2005 7:45 pm
by feyd
Posted: Sun Mar 06, 2005 7:57 pm
by pleigh
thanks feyd....i did this
Code: Select all
if (isset($_SESSIONї'userID']))
{
header('Location: login.php');
}
else
{
session_start();
require_once ('dbconnect.php');
}
but it opens the index page, or other pages, instead of redirecting to the login page....undefined indexes still prompts me....
Posted: Sun Mar 06, 2005 8:05 pm
by Burrito
you probably want to move that session start...
and you probably want to try if(!isset())
since you want to determine if the session var exists.
Posted: Sun Mar 06, 2005 8:15 pm
by pleigh
i did this
Code: Select all
if (!isset($_SESSIONї'userID']))
{
header('Location: login.php');
}
it redirects, but the same problem occur during login....it doesn't log me in my index page
Posted: Sun Mar 06, 2005 8:18 pm
by Burrito
did you move the session start?
if not, then it won't know that the session var is defined?
Posted: Sun Mar 06, 2005 9:05 pm
by pleigh
yes, i removed it but the same thing happens....
Posted: Sun Mar 06, 2005 9:07 pm
by Burrito
not REmove...just move it above the isset
otherwise, it'll never be set on that page and it will always redirect you.
[SOLVED]
Posted: Sun Mar 06, 2005 9:12 pm
by pleigh
thanks....it perfectly works well now....
