0

I am trying to redirect the page to specific page based on the function return type.

i am using the php header() to do so. but when i load the page i am getting the error message

 Cannot modify header information - headers already sent by (output started at 

what is the fault here?

here is what i have done

 <?php 
      if(ifproductPublished($qs) == true){
          header('Loaction: not-found.php');
        } elseif(ifproductValid($qs) == false){
          header('Location: not-found.php');
        } else {
        ?>
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <div class="panel panel-default">
        ...
 ?>

How can i resolve this?

CJAY
  • 6,989
  • 18
  • 64
  • 106

2 Answers2

0

Remove any whitespace before your <?php tag. If you have any output before the header line it fails this includes stuff before the php script starts.

Niki van Stein
  • 10,564
  • 3
  • 29
  • 62
0

Make sure you do not output before header function . But if you need it by any way just add

ob_start()

at first line

ob_flush()

at last line

This will tell your server you will output your page after complete execution not in partial..

Rohit Kumar
  • 1,948
  • 1
  • 11
  • 16