Problem with redirecting to login page

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
lidds
Forum Newbie
Posts: 5
Joined: Mon Oct 20, 2003 10:22 am
Location: UK

Problem with redirecting to login page

Post by lidds »

Could anyone help..... I have written a simple login script that requires a username and password to be entered, this information is then passed to the main page of my application. Within the main page it connects the database and checks the username and password, if they do not match it redirects back to login page (this works fine).

The problem comes when I need to navigate back to my main page from a different page using a link. It then takes me back to my login page rather than the main page as specified in my link. I assume it is doing this because information is required to be posted from my login page to the main page? Is this the case? If so, is there anyway around it not going back to the login page each time?

Cheers

Simon
leoden
Forum Newbie
Posts: 21
Joined: Sat May 24, 2003 8:48 pm

Post by leoden »

Whats the code at the top of the page? have you specified any headers?
mhorner
Forum Newbie
Posts: 5
Joined: Fri Oct 17, 2003 12:55 pm
Location: Wauwatosa, WI
Contact:

Post by mhorner »

Sounds like to me that you need to get this information through the login page first. I have a similar scheme that I built, and if the username and the password are not specified through the form or session state, the login information is brought up.

I would figure that you would rather have people authenticate.

--- OR ---
Are you saying that after you are passed the login page, and you are trying to use the system you are getting bounced back to the login page? If you are, then you can get around this in two ways..
1. Pass the user name and password through the forms (put them in hidden values in the page)
2. Put the information into a session. Which all information is stored on the server and is retrieved by an identifier. (more secure than 1.)

With 2 you can check the form information if nothing is present for the login, then check the session.

HTH!
Matt
Post Reply