-3

I tried a code on my LocalHost server and it worked perfectly , but when i uploaded the page on web server this redirection function not working :

header('location:ControlPanel/Add_course.php');

Any hint how to fix it ?

Thomas Rollet
  • 1,573
  • 4
  • 19
  • 33
Montaser Qasem
  • 117
  • 2
  • 11

2 Answers2

2

remove all the print statements and echo statements in that page I mean if you are redirecting in main page remove unwanted print and echo as well as ?> . I also had this issue

2

header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP

Combine all your PHP codes and make sure you don't have any spaces at the beginning of the file.

It should be Location not location.

also after header('Location:ControlPanel/Add_course.php'); add exit(); if you have any other scripts below.

If still problem exist, use ob_start() and try below code:-

 ob_start();
 header('Location:ControlPanel/Add_course.php');
 exit();

If none of them working then only use Js syntax to redirect by below way:-

echo "<script type='text/javascript'> document.location = 'ControlPanel/Add_course.php'; </script>";

Hope it will help you :)

Ravi Hirani
  • 6,511
  • 1
  • 27
  • 42