header()... again ;-)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
so, no output can occur before a header is called.  i think this means

if i have a relatively positioned top div, a left div and a right div
(both below top div) and i want to run some code in my right div and
refresh the page when data is entered page, i can't do this using
header b/c i've already output html to create the formatting of top div
and left div.

is this so?  if so, and i think it is (cry...), are there any work

i have coded a really nice form, but i need to "refresh" it in order to
clear the entered data from the text box.  using header() actually
works perfectly on my winxp development box, but i uploaded it to my
production linux server and got the following love note...

Warning: Cannot modify header information - headers already sent by
(output started at /home/db/public_html/includes/header.inc.php:7) in
/home/db/public_html/enter_customer.php on line 130.

on line 130 i call header().  on line 7 of header.inc.php you'll find
me using a constant to print my web pages title.
tia for any guidance...

soooooooo close, too...  -lol-

Re: header()... again ;-)

skeeterbug wrote:

Quoted text here. Click to load it

You either have to move your programming logic to be *before* the html
output (and it's always better to separate the code and the content) or
use output buffering. http://www.php.net/ob_start

Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com /

Re: header()... again ;-)

chris, thanks.

i need to learn a little more about ob_start - i tried to use it, but i
think my lack of arguments "ob_start()" caused php to quit.

i would separate the logic, but i *really* don't know how.  the header
is only called when $_session[] has been a value.

this occurs well into my code (4th relative div section, to be more
accurate.  come to think of it, though, if the header is actually
called, nothing needs to print b/c it won't ever be viewed due to the
i might have to print out this code and ponder this for a bit.

Re: header()... again ;-)

I noticed that Message-ID:
contained the following:

Quoted text here. Click to load it

Exactly.  Instead of printing it you could simply assign it to a
variable.  Then print the variable if the page is not redirected.
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker /

Re: header()... again ;-)


for any newbies looking to assign lots of html to a variable, heredocs
may be something they want to look into.

back to my problem of structure.  looking at an oversimplification,
take a small section of code in the middle of my html that will change
depending on if an error is input or if the input is valid.

i'm thinking that i could assign 4 variables.

$var1 = "html prior to decision tree" (is error or valid and take the
appropriate action...
$var2 = "do this if input error occurs"
$var3 = "do this if input valid"
$var4 = "html after decision tree"

i would then run my php code and...

if error... print($var1 . $var2 . $var4)

if valid... print($var1 . $var3 . $var4)

is this a reasonable approach or am i missing something?  is there a
better way?  i'm not necessarily looking for a php guru status solution
that will take 6 months of background to comprehend (i'm numb already
-lol-).  i'm looking for something that is reasonable and doesn't
represent rope tied in a loop that will lower over my php head in 6
months...  -lol-


ps - my case is actually more complicated, but i could easily
extrapolate this solution by adding more variables.

Geoff Berrow wrote:
Quoted text here. Click to load it

Re: header()... again ;-)

i've done a bit of research and it looks like i may go with phpsavant
template class...


the link gives a simple example of how to separate business logic from
content.  smarty might also work very well...  but, frankly, i don't
want to expend the time to *learn* the smarty language - compiling time
really wouldn't be an issue since my app will run on the same

smashed head on another rock...  might have found a detour around
rock...  -lol-

Site Timeline