Jump to content

Custom Erro Handling


Crew-Portal

Recommended Posts

Hi I am making a website that has a user registration. All files on the site have a error handling system that displays the error at the top of the page if a form is handled incorectly. I have just been using scripts like if $_POST[name] == NULL {$errormsg = Name is not filled }

 

Now I realize that script is wrong but thats not the point. Whenever there is an error it gets called as a diffrent variable and that is displayed at the top of the page and if the error equals Null as in unassigned it displays nothing! This process works fine but it only displays one error and exits the script. I would like to know how to make a error handling system that will display all errors at one something like:

 

Username Not Filled.

Password Incorrect.

Email Not Entered.

 

Something like that displaying all the errors on a form at one time

Link to comment
https://forums.phpfreaks.com/topic/63330-custom-erro-handling/
Share on other sites

Personally, I use sessions for my error-handling.  However, one option would be to initialize $errormsg to NULL at the begining of the script, then use $errormsg .= "Username not entered<br />";

 

This will contatenate the messages, and the <br /> will insert a break (future error messages will be printed on the next line)

Link to comment
https://forums.phpfreaks.com/topic/63330-custom-erro-handling/#findComment-315600
Share on other sites

Your method should still work.  Anytime I output the $_SESSION['failmessage'] on mine, I then unset($_SESSION['failmessage']);

 

My script bounces to several pages, and I want the data to be available for the "final resting place" of the client, so to speak.

Link to comment
https://forums.phpfreaks.com/topic/63330-custom-erro-handling/#findComment-315612
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.