By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

header()... again ;-)

P: n/a
so, no output can occur before a header is called. i think this means
that...

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
arounds?

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-

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
skeeterbug wrote:
so, no output can occur before a header is called. i think this means
that...

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
arounds?

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-


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/
Jul 17 '05 #2

P: n/a
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
redirect.
i might have to print out this code and ponder this for a bit.

Jul 17 '05 #3

P: n/a
I noticed that Message-ID:
<11*********************@c13g2000cwb.googlegroups. com> from skeeterbug
contained the following:
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
redirect.


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/
Jul 17 '05 #4

P: n/a
geoff,

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-

tia...

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


Geoff Berrow wrote:
I noticed that Message-ID:
<11*********************@c13g2000cwb.googlegroups. com> from skeeterbug contained the following:
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 theredirect.


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/


Jul 17 '05 #5

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

http://phpsavant.com/yawiki/index.ph...=SavantExample

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
computers.

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

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.