Newbie PHP Question

Status
Not open for further replies.
Jumping headfirst into some PHP programming for a senior project. Not done PHP (or web development at all) before this so I'm having to do a lot of learning on the fly - which is almost how I prefer it.

Anyways - We have the site setup so that if you visit a page that requires authentication, it bounces you back to the login page. What is the best way to pass data to the login page so that it intelligently displays a message like "That action requires authentication."? We'd presumably use this to display a message when the username/password is incorrect as well.
 

Drizzt321

Ars Legatus Legionis
34,925
Subscriptor++
Indeed, unless otherwise prohibited, frameworks can help push any project in a generally better direction, structure-wise. Which is a very good thing. If otherwise prohibited, there are a couple of possible methods.

One, put data in the Session, put data into the URL as a GET parameter, send it via a Cookie (which is one method that Sessions use, the other is a GET parameter).

Alternatively, you can simply render the login page, instead of redirecting the user to a separate URL that is the login page. This is usually aided by using a proper MVC framework which Authentication controller chooses to render the Login view instead of whatever would normally be at that page.

Following the KISS principle, use a GET parameter or a Session to pass the data between pages.
 
Status
Not open for further replies.