weird problem?

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
raindrophk
Forum Newbie
Posts: 4
Joined: Thu Nov 27, 2003 4:07 pm

weird problem?

Post by raindrophk »

Webserver setting: Php version 4.1.2

I am writing a login page by using $_SESSION[].
I tested it on my local computer(localhost), it works fine.
However, when I uploaded to the webserver, it doesn't work propertly. It displayed the error message that what I created "Failed to login, this is a restricted page".
I can login into the first page, when I click the second page links, it can't log me in unless I refresh this page several times.

For example, I have 3 pages, login.php, firstpage.php, and secondpage.php
Code on firstpage.php and secondpage.php
if(!isset($_SESSION['valid_admin'])) {
//Error message if it failed to login.
die("Failed to login, this is a restricted page.");
}
print("Logined successful. <i>Welcome < ".$_SESSION['valid_adm']."> </i>");

I type the username and password on login.php,
I can log in to firstpage.php,
when I click the link of secondpage.php on firstpage.php,
I cannot log in until I clicked the "Refresh" button on IE several times.
I don't know what causes this problem? Is it because my webserver is too slow since this webserver have a lot of traffic?
Did anyone know what happened? Please, help me if you knew the solution.
Thank you,

Raindrop
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

you need to put

Code: Select all

session_start();
on firstpage.php and secondpage.php.
raindrophk
Forum Newbie
Posts: 4
Joined: Thu Nov 27, 2003 4:07 pm

Simplified my question.

Post by raindrophk »

Above message maybe little bit confused, so I am simplified my question.
Why I cannot login in the first time unless I refresh this page several times.
But this page is working fine on my local computer.
Is it because of the traffic of the server. I feel little bit slow on that server. I felt like the session can not created before it checked on my if-statement.
The scene of my problem:
1) Type the username and password on login page, and send it to admin page.
2) Get this error in the first time: "Failed to login, this is a restricted page"
3)Clicked "Refresh" button several times.
4)I can log in. Get this message: Logined successful. Welcome! Admin

code of login validation:
if(!isset($_SESSION['valid_adm'])) {
//Error message if it failed to login.
die("Failed to login, this is a restricted page.");
}
print("Logined successful. <i>Welcome < ".$_SESSION['valid_adm']."> </i>");
raindrophk
Forum Newbie
Posts: 4
Joined: Thu Nov 27, 2003 4:07 pm

Not missed session_start

Post by raindrophk »

Thank you for your reply.

I have sesson_start() on all 3 pages.
And, I have a question if i only missed session_start(), how come it work on my local computer and work after I clicked "Refresh" several times.
raindrophk
Forum Newbie
Posts: 4
Joined: Thu Nov 27, 2003 4:07 pm

?????

Post by raindrophk »

No one has the same problem before?
Or nobody knew how to fix this?
Post Reply