Re: Warning: Cannot modify header information

From: Markus Ernst (derernst_at_NO#SP#AMgmx.ch)
Date: 01/14/04

  • Next message: Toby A Inkster: "Re: How do I prevent this from happening? (long text pushing out a fixed frame)"
    Date: Wed, 14 Jan 2004 08:51:42 +0100
    
    

    "Markansas" <markansas61@yahoo.com> schrieb im Newsbeitrag
    news:cdi8005hkcvplh08n40mn453941v0b2858@4ax.com...
    >
    > No that code was the poll.php file itself.
    >
    >
    > I had looked into the header.php and founf that the line 6 was the
    > start of a Javascript. I removed the javascript and it all works fine.
    >
    > If there is ANY mention of javascript in the header.php <head> tags or
    > right even after the <body> the error appears.
    >
    > Also it don't matter WHAT the javascript code is, as long as there is
    > a javascript code of some sort, the error appears.
    >
    > Take OUT the javacript and all works fine.

    It is not because it is javascript but because you output something to the
    client at all. As a cookie is a http header you have to set it before _any_
    output to the client.

    My suggestion is as follows:
    - At the beginning of poll.php set 2 variables:
      $message = "";
      $displayform = 0;
    - Change all echo commands from echo "something"; to $message .=
    "something";
    - Change all display_form(); commands to displayform = 1;
    - At the position where poll.php is included now replace it by:
      echo $message;
      if(displayform==1) display_form();
    - Include the poll.php script at the very top of the code in the main page,
    or at least _before_ any <html> or <doctype> tags

    Now the cookie is set before the output starts.

    HTH
    Markus


  • Next message: Toby A Inkster: "Re: How do I prevent this from happening? (long text pushing out a fixed frame)"

    Relevant Pages

    • Re: executing javascript and vbscript
      ... by javascript, so the request pulls the old value. ... Communication between the server and the client happens in one direction at ... So the cookie is set using your client side JavaScript AFTER all the cookies ...
      (comp.lang.javascript)
    • Re: COOKIE EXPIRATION TIME
      ... You could use a javascript to enter the client's time into a hidden form ... the client machine. ... > According to the documentation cookie expiration time is set via ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: Getting the referer info into a form field?
      ... conditionally stored the referer in a Cookie, only if the referer was not ... and if the Cookie did not exist already (which would ... JavaScript alone, though, nice thinking - yes, a Cookie would be the way to ... >> Kevin Spencer ...
      (microsoft.public.frontpage.programming)
    • Re: [Full-disclosure] Google / GMail bug, all accounts vulnerable
      ... JavaScript code was being loaded. ... This would work if the session cookie is restricted to ... then google did two things. ... GMail account, but has nothing to do with CAPTCHAs. ...
      (Full-Disclosure)
    • PageLoad when BACK is clicked
      ... Basically I think you could do this by JavaScript. ... And then also create a cookie with a timestamp (and set it ... Retrieve the hidden form field value (into a var ... Otherwise reload the page. ...
      (microsoft.public.dotnet.framework.aspnet.webcontrols)