Jump to content

Sending an error message


arenaninja

Recommended Posts

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 :D

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.