I have a page Admin.php, at the top is the following code. it is supposed to direct the user to the Login.html page if he is not authorized first. However, when I type http://localhost/Admin.php, I can still view this page, not being directed to the login page instead. Please advise.
Of couse, in the authorization page, I have some code like this:
if (ocifetch($stmt)){
session_start();
session_register('username');
header("Location: Main.php");
}
else {
header("Location: index.html");
}
------------------Admin.php----------------
<?php
session_start();
if(!(session_is_registered('username'))){
header ("Location Login.html");
} else {
?>
<html>blah....</html>
problem with session
Moderator: General Moderators
-
jiehuang001
- Forum Commoner
- Posts: 39
- Joined: Mon May 12, 2003 12:53 pm
The file name is "Main.php"
I said "Admin.php". Actually its name is "Main.php"
-
jiehuang001
- Forum Commoner
- Posts: 39
- Joined: Mon May 12, 2003 12:53 pm
-
jiehuang001
- Forum Commoner
- Posts: 39
- Joined: Mon May 12, 2003 12:53 pm
Well, let's say, now I only have one page "Main.php". If the user type http://myurl/Main.php directly, I will send him to http://www.cnn.com. If the user login first, he will see this page. Can you tell me how to do that?
The following doesn't work. Also, I put "session_start()" at the VERY top of the authorization page, it still doesn't work.
<?php
session_start();
if(!(session_is_registered('username')))
header ("http://www.cnn.com");
?>
The following doesn't work. Also, I put "session_start()" at the VERY top of the authorization page, it still doesn't work.
<?php
session_start();
if(!(session_is_registered('username')))
header ("http://www.cnn.com");
?>
-
JPlush76
- Forum Regular
- Posts: 819
- Joined: Thu Aug 01, 2002 5:42 pm
- Location: Los Angeles, CA
- Contact:
<?php
session_start();
if(!isset($_SESSION['sessionvar']))
{
header ("http://www.cnn.com");
}
?>[/quote]
session_start();
if(!isset($_SESSION['sessionvar']))
{
header ("http://www.cnn.com");
}
?>[/quote]