PHP exit makes my code work

josephberlin

New Member
Can't quite believe I'm asking this question but here goes....(Using PHP within Codeigniter)I am integrating Barclays EPDQ into an e-commerce site for taking credit card payments. On successful payment EPDQ redirects back to the site passing query string parameters in the URL. I am looking for the orderID sent back from EPDQ, if its there I store a few things in the PHP session and redirect to the payment confirmation page. If the payment was unsuccessful the order ID won't be there and so I redirect to a payment failed method which shows a CI view file. The condition for this check and session save routine is as follows:\[code\]$success = false;if($_GET['orderID']){ $_SESSION['payment']['order_id'] = $_GET['orderID']; $_SESSION['payment']['method'] = 'card'; $_SESSION['payment']['ref'] = $_GET['PAYID']; $_SESSION['payment']['status'] = 'Completed'; $success = true;}\[/code\](please note the session is initialised and the payment array created prior to this code executing)Pretty simple so far, right. The code for the directions then looks like this:\[code\]if(!$success){ redirect('payment/card/fail');}else{ redirect('payment/confirmation');}\[/code\]The issue I am having is that this redirection doesn't work as I would expect. EPDQ reports successful payment and redirects back to our site as required. However when my script evaulates the GET parameters that it sends and goes to do the redirect it always uses the failed redirection............unless, and this is the bit that is really stumping me, I do this:\[code\]if(!$success){ exit('Failed'); redirect('payment/card/fail');}else{ redirect('payment/confirmation');}\[/code\](note the added 'exit').Once I include this exit the code executes as desired in all test cases and we start to see the payment success page. Removing the exit immediately reverts back to 100% tests failing.Does anyone have any idea why this is happening as I've not ever seen this before?
 
Top