-1

I am trying to integrate 2checkout.com API. When I skip header function then its working fine. Presently it displaying same php code as output

if ($charge['response']['responseCode'] == 'APPROVED') {
    //echo "Thanks for your Order!";
    header("Location: /servlet/Payment?option=1&msg=0");
    exit(0);   
}else{
    $replyError = $charge['response']['responseCode'];
    header("Location: /servlet/Payment?option=2&msg=".$replyError);
    exit(0);
    //echo '<pre>';print_r($charge['response']['responseCode']);echo'</pre>';
    }       
} catch (Twocheckout_Error $e) {echo $e->getMessage();}
Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34
LifeSaver
  • 138
  • 4
  • 10

2 Answers2

0

You cannot emit a header after the page's html starts being emitted.

rsjaffe
  • 5,600
  • 7
  • 27
  • 39
0

Instead of header() method use javascript method for redirection like below:

echo '<script>window.location="http://stackoverflow.com";</script>';
Amit Rajput
  • 2,061
  • 1
  • 9
  • 27