Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login Methods and Redirect

Status
Not open for further replies.

Shanksta

Technical User
Joined
Jun 28, 2002
Messages
96
Location
US
I read a ton of literature on login methods, and wanted to ask which is easier/most used.

1. having 1 pages with an if statments (if not logged in then display login screen, if logged in show content)
2. 2 seperate pages

on a side note, how can i redirect users to another page in php?
 
First, the easy question.

You redirect a browser to another script on your server (or any page on any server) through the use of PHP's header() function, by setting a "Location" header. An example is on the page in the link.


My own method for producing a site is to have a single script produce an HTML page and then also process the data submitted from that page. If the processing of the data is successful, the script uses a "Location" header to send the browser to the next script in the sequence. Otherwise, the script reproduces the page with error messages.

In terms of logging in a user, I generally have the script behave as in the previous paragraph. In addition, when the processing of the data succeeds (the credentials entered by the user are successfully authenticated) the script will also set a session variable which notes that the user successfully logged in and what that user's userid is.

Then all scripts in the site which require a login can easily check for good user credentials and either produce output (when there are good credentials) or use send a "Location" header to the login page (when there are no good credentials).



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top