arenaninja Posted February 19, 2012 Share Posted February 19, 2012 hey everyone. I'm working on a site (built almost from scratch) and i used a book which implements a design i'm not all too confident about, but i'll try it out. Anywho there is one thing that bugs me, and that is that I don't know how to properly setup error messages. For example, the login page does this: * gather data * send $_POST data to process.inc.php * process.inc.php handles the object implementation, and sends you to the dashboard if your login is successful and returns you to the login page if the login attempt is unsuccessful However, on the last one, if I have to send the user back to the page because of a failed attempt, i'd like to display an error message, but I'm not clear on the best way of doing this considering the request isn't handled by PHP_SELF. I hope I made sense. If not, I'll gladly try to clear up any confusion, and thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/257323-sending-an-error-message/ Share on other sites More sharing options...
codebyren Posted February 19, 2012 Share Posted February 19, 2012 It would be a lot easier to go with the standard of having the same code that generates the form, process the form. But since you've been guided down this unfortunate path (at least in my view) , you could look into sessions. Sessions can be used to store data between/across page requests so you can: 1. Store a copy of the $_POST array in the session so you can repopulate the form with the user's previously entered data 2. Store the validation error messages in the session The session data will then still be available after the user has been redirected back to the login form and you can handle it as appropriate (and remove it from the session when you're done) Quote Link to comment https://forums.phpfreaks.com/topic/257323-sending-an-error-message/#findComment-1318982 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.