Hello
When developing an application, exceptions (errors) can occur. I noticed that using the header( “Location” directToPage.php ), redirects to the page even if errors occur. I also noticed that it has to be the first line in the php code.
So I am curious, how do others use redirect logic when exceptions (errors) occur? For example:
Any feedback is appreciated.Code:<?php //-- I have to put the redirect here for it to work header( “Location” successPage.php ); //-- I use a Data Access object to insert data but the insert fails //-- so instead of directing to successPage.php, I need to direct to errorPage.php $dao = new InsertDAO(); If( $dao.insert() ) { //-- successful insert, let successPage.php redirect occur } else { //-- here is where the failed insert is caught… I now want to direct to //-- the errorPage.php but I am not sure how I can… this does not work header( “Location” errorPage.php ); }






Bookmarks