trouble in using include and header in php. "Cannot modify header information" -


this question has answer here:

i have file 'header.php' has search text box in it. file called 'mypage.php' includes 'header.php'. in header.php

 if (isset($_post['searchbutton'])){ // execute when search button clicked.  $target = $_post['searchtext'];  header("location: searchresult.php?text=" . $target); // line #8  } 

in mypage.php

<?php include("header.php"); ?> 

when i'm on "mypage.php" , use search option, error says

cannot modify header information - headers sent (output started @ mypage.php:3) in header.php on line 8. 

can please me understand concept. i'm newbie php. please ask if more info required.

cheers!

you can not output browser before send header(). have @ how http works , you'll understand :)

http://en.wikipedia.org/wiki/hypertext_transfer_protocol#client_request


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -