How should I handle site feedback messages (success/errors) to the user in PHP?

211 views Asked by At

Such as "Username not found", "Problems logging you off", "Logout successful", and so on. Any feedback the website needs to give the user.

I made a class Feedback_Messages, declaring in instance of itself upon running (called in the page header). All messages are stored in a 3D array, according to message type (i.e. error, positive,...). A Get Message function prints out all of the waiting messages (I can make it look fancy when it's done).

Sometimes it works. Before I get into debugging, is this even a good way of doing this, or is there a best practice or available project to manage messages from different class objects to the user? Maybe in session? I'm new to php.

Thanks!

1

There are 1 answers

0
StringsOnFire On BEST ANSWER

Use a 'flash' system to store the message in session, and display it on the next page viewed before removing the flash.