chris_s_22 Posted January 9, 2009 Share Posted January 9, 2009 when been doing the coding i notice that when ive tested each function to make sure everything working that when a error is displayed it goes to a blank page and displays it, what i want is one page that i can customise and disaplays the error on that page, here are all my errors else { echo "Wrong Confirmation code";} die ('Could not connect to the database.'); can i replace the above errors with the following code without a problem? // show error page with the error $reg_error = description of the error here'; include 'error.php'; exit; then on the error page have something like <?php if (isset($login_error)) { ?> There was an error: <?php echo $login_error; ?>, please try again. <?php } ?> is there any reason why this wouldnt work or is there a simpler way Link to comment https://forums.phpfreaks.com/topic/140218-handling-error-codes/ Share on other sites More sharing options...
flyhoney Posted January 9, 2009 Share Posted January 9, 2009 You could create a generic error page and when you come across an error, use a function like this: <?php function error($msg) { header('Location: error.php?msg=' . $msg); exit; } ?> And then your error page would be a simple page that just displays the error message from the GET variable: <?php if (isset($_GET['msg'])): ?> There was an error: <?php echo $_GET['msg']; ?>, please try again. <?php endif; ?> So when you come across an error: <?php else { error("Wrong Confirmation code"); } ?> Link to comment https://forums.phpfreaks.com/topic/140218-handling-error-codes/#findComment-733695 Share on other sites More sharing options...
chris_s_22 Posted January 9, 2009 Author Share Posted January 9, 2009 what about the die ('Could not select database.'); also there are a few errors i want to be displayed on certain pages eg if register with a black feild i wont that error to be displayed on that form page Link to comment https://forums.phpfreaks.com/topic/140218-handling-error-codes/#findComment-733718 Share on other sites More sharing options...
flyhoney Posted January 9, 2009 Share Posted January 9, 2009 Same thing: error('Could not select database.'); Link to comment https://forums.phpfreaks.com/topic/140218-handling-error-codes/#findComment-733720 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.