0

I have a couple of .php scripts which I am trying to redirect from when they have been send. These .php file are used to alot of things, such as email sign up and charging of cards through the payment service Stripe. It worked without any problems when I tried it on my local host, but now that I have uploaded my site to my Hostgator account I get the following error.

Warning: Cannot modify header information - headers already sent by (output started at /home1/ab56403/public_html/chargeCard.php:1) in /home1/ab56403/public_html/chargeCard.php on line 50

This is how I am trying to redirect, I have this code in the bottom of every .php script I am using.

header('Location: index.html');
exit;
Sm00rf9000
  • 531
  • 1
  • 7
  • 20
  • 2
    If there is any `echo` (or other output) before `header()`, `header()` will not work. This is because PHP has to send HTTP response headers to the client before sending any part of the HTTP response body, so any output will trigger sending headers and prevent any subsequent calls to `header()`. – Michael Jaros May 02 '15 at 12:44
  • 1
    Thank you for the help, I have figured out how to fix it. – Sm00rf9000 May 02 '15 at 13:10

0 Answers0