header()... again ;-)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • skeeterbug

    #1

    header()... again ;-)

    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-

  • Chris Hope

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

    skeeterbug wrote:
    [color=blue]
    > 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-[/color]

    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/

    Comment

    • skeeterbug

      #3
      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
      redirect.
      i might have to print out this code and ponder this for a bit.

      Comment

      • Geoff Berrow

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

        I noticed that Message-ID:
        <1105854504.918 919.67680@c13g2 000cwb.googlegr oups.com> from skeeterbug
        contained the following:
        [color=blue]
        >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.[/color]

        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/

        Comment

        • skeeterbug

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

          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 oversimplificat ion,
          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:[color=blue]
          > I noticed that Message-ID:
          > <1105854504.918 919.67680@c13g2 000cwb.googlegr oups.com> from[/color]
          skeeterbug[color=blue]
          > contained the following:
          >[color=green]
          > >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[/color][/color]
          the[color=blue][color=green]
          > >redirect.[/color]
          >
          > 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/[/color]

          Comment

          • skeeterbug

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

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

            Comment

            Working...