Which is the best method for error handling, and really used one while building secured websites?
Whenever the error occured, it must be shown to the users, and must resume the next process.
Printable View
Which is the best method for error handling, and really used one while building secured websites?
Whenever the error occured, it must be shown to the users, and must resume the next process.
uhh. it really depends on the way you're implementing your website and what errors you're talking about.
if you're talking about custom errors (for example, when a user enters an incorrect username or password), you could simply have an array named $errors that kept track of any errors that occurred. that is, of course, pretty much the absolute simplest way of doing it -- but it might fit with how you're doing things given your knowledge of the language.
if you're talking about run-time errors, however, then you should be fixing the bugs and programming defensively so that these errors do not occur, rather than trying to display them to the user.
try to be a bit more specific.
Ya i meant for runtime errors only. Ya normally on a real websites how are they handling errros?
Like kows said you should really be programming defensively so you do not get any runtime errors (notices, warnings + errors).
You should never display these to your user, it could reveal a flaw in your system and allow them to take advantage of it.
php Code:
error_reporting(0); @ini_set('display_errors', 0);
http://www.lost-in-code.com/platform...oduction-site/
I recommend using global error handler and global exception handler functions to catch runtime errors in a production environment.
Is there a way to capture the error, and have it emailed to yourself, instead of being shown to the user? Like some function you can use that is similar to mysql_error()?
It seems like a good idea to either have the error messaged emailed to the webmaster, with all the page and connection details so they can evaluate it, or have them stored in a table (assuming there is some kind of admin backend).
Use one or both of the functions I suggested, and write some code to send the email in there.
(Aside: If your error handling function throws an error itself, the default error handler is used.)