Loading ...
Sorry, an error occurred while loading the content.

Warning : Headers already sent

Expand Messages
  • bhatavanti
    Hi, If I try to redirect a page to another page using Header(), I am getting warnings : Warning: session_start() [function.session-start]: Cannot send session
    Message 1 of 5 , Mar 8, 2010
    • 0 Attachment
      Hi,

      If I try to redirect a page to another page using Header(), I am getting warnings :

      Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php:2) in /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php on line 16

      Warning: Cannot modify header information - headers already sent by (output started at /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php:2) in /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php on line 27

      Here is the code :


      <?PHP
      include("connect.php");
      $username = $_POST['username'];
      $password = $_POST['password'];
      $result=mysql_query("select * from customerlogin where custname='$username' AND custpassword='$password'");
      $rowCheck = mysql_num_rows($result);

      //echo $rowCheck;
      if($rowCheck > 0)
      {

      // while($row = mysql_fetch_array($result))
      //{
      $login="success";
      session_start();
      $_SESSION['loginid']=$username;

      } else {
      $login="fail";
      echo "Incorrect Username password";
      //header("Location: h.html");
      // echo $username;
      }

      if($login=="success"){
      header("Location: home.php");
      //echo "jgfuh";
      }
      ?>

      Please help
    • munim2020
      Like I explained in my last email, you can use header to modify the header output only if nothing else has been outputted before that. I can see some echos and
      Message 2 of 5 , Mar 9, 2010
      • 0 Attachment
        Like I explained in my last email, you can use header to modify the header
        output only if nothing else has been outputted before that. I can see some
        echos and session setting code.. all this is output which can't come before
        the header.


        On 9 March 2010 13:06, bhatavanti <bhatavanti@...> wrote:

        >
        >
        > Hi,
        >
        > If I try to redirect a page to another page using Header(), I am getting
        > warnings :
        >
        > Warning: session_start() [function.session-start]: Cannot send session
        > cache limiter - headers already sent (output started at
        > /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php:2) in
        > /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php on line 16
        >
        > Warning: Cannot modify header information - headers already sent by (output
        > started at /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php:2) in
        > /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php on line 27
        >
        > Here is the code :
        >
        > <?PHP
        > include("connect.php");
        > $username = $_POST['username'];
        > $password = $_POST['password'];
        > $result=mysql_query("select * from customerlogin where custname='$username'
        > AND custpassword='$password'");
        > $rowCheck = mysql_num_rows($result);
        >
        > //echo $rowCheck;
        > if($rowCheck > 0)
        > {
        >
        > // while($row = mysql_fetch_array($result))
        > //{
        > $login="success";
        > session_start();
        > $_SESSION['loginid']=$username;
        >
        > } else {
        > $login="fail";
        > echo "Incorrect Username password";
        > //header("Location: h.html");
        > // echo $username;
        > }
        >
        > if($login=="success"){
        > header("Location: home.php");
        > //echo "jgfuh";
        > }
        > ?>
        >
        > Please help
        >
        >
        >



        --
        Abdul Munim Kazia
        mail@...


        [Non-text portions of this message have been removed]
      • Chaitanya Yanamadala
        why dont u try using the meta refresh instead of header. echo ; Chaitanya A man can get discouraged
        Message 3 of 5 , Mar 9, 2010
        • 0 Attachment
          why dont u try using the meta refresh instead of header.

          echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=home.php\">";

          Chaitanya

          "A man can get discouraged many times but he is not a failure until he stops
          trying..."

          "I would love to change the world, but I can't get the source code."



          On Tue, Mar 9, 2010 at 3:50 PM, munim2020 <munim2020@...> wrote:

          >
          >
          > Like I explained in my last email, you can use header to modify the header
          > output only if nothing else has been outputted before that. I can see some
          > echos and session setting code.. all this is output which can't come before
          > the header.
          >
          >
          > On 9 March 2010 13:06, bhatavanti <bhatavanti@...<bhatavanti%40yahoo.com>>
          > wrote:
          >
          > >
          > >
          > > Hi,
          > >
          > > If I try to redirect a page to another page using Header(), I am getting
          > > warnings :
          > >
          > > Warning: session_start() [function.session-start]: Cannot send session
          > > cache limiter - headers already sent (output started at
          > > /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php:2) in
          > > /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php on line 16
          > >
          > > Warning: Cannot modify header information - headers already sent by
          > (output
          > > started at /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php:2)
          > in
          > > /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php on line 27
          > >
          > > Here is the code :
          > >
          > > <?PHP
          > > include("connect.php");
          > > $username = $_POST['username'];
          > > $password = $_POST['password'];
          > > $result=mysql_query("select * from customerlogin where
          > custname='$username'
          > > AND custpassword='$password'");
          > > $rowCheck = mysql_num_rows($result);
          > >
          > > //echo $rowCheck;
          > > if($rowCheck > 0)
          > > {
          > >
          > > // while($row = mysql_fetch_array($result))
          > > //{
          > > $login="success";
          > > session_start();
          > > $_SESSION['loginid']=$username;
          > >
          > > } else {
          > > $login="fail";
          > > echo "Incorrect Username password";
          > > //header("Location: h.html");
          > > // echo $username;
          > > }
          > >
          > > if($login=="success"){
          > > header("Location: home.php");
          > > //echo "jgfuh";
          > > }
          > > ?>
          > >
          > > Please help
          > >
          > >
          > >
          >
          > --
          > Abdul Munim Kazia
          > mail@... <mail%40munimkazia.com>
          >
          > [Non-text portions of this message have been removed]
          >
          >
          >


          [Non-text portions of this message have been removed]
        • Amardeep
          Hi, Like munim said you can not print any out put before calling the PHP header function. Also it is advisable to call session_start() before any text is sent
          Message 4 of 5 , Mar 9, 2010
          • 0 Attachment
            Hi,

            Like munim said you can not print any out put before calling the PHP header
            function.
            Also it is advisable to call session_start() before any text is sent to the
            browser.

            On Tue, Mar 9, 2010 at 3:50 PM, munim2020 <munim2020@...> wrote:

            >
            >
            > Like I explained in my last email, you can use header to modify the header
            > output only if nothing else has been outputted before that. I can see some
            > echos and session setting code.. all this is output which can't come before
            > the header.
            >
            >
            > On 9 March 2010 13:06, bhatavanti <bhatavanti@...<bhatavanti%40yahoo.com>>
            > wrote:
            >
            > >
            > >
            > > Hi,
            > >
            > > If I try to redirect a page to another page using Header(), I am getting
            > > warnings :
            > >
            > > Warning: session_start() [function.session-start]: Cannot send session
            > > cache limiter - headers already sent (output started at
            > > /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php:2) in
            > > /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php on line 16
            > >
            > > Warning: Cannot modify header information - headers already sent by
            > (output
            > > started at /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php:2)
            > in
            > > /home/content/a/g/a/agani/html/G/Mithaiwale/testing/l2.php on line 27
            > >
            > > Here is the code :
            > >
            > > <?PHP
            > > include("connect.php");
            > > $username = $_POST['username'];
            > > $password = $_POST['password'];
            > > $result=mysql_query("select * from customerlogin where
            > custname='$username'
            > > AND custpassword='$password'");
            > > $rowCheck = mysql_num_rows($result);
            > >
            > > //echo $rowCheck;
            > > if($rowCheck > 0)
            > > {
            > >
            > > // while($row = mysql_fetch_array($result))
            > > //{
            > > $login="success";
            > > session_start();
            > > $_SESSION['loginid']=$username;
            > >
            > > } else {
            > > $login="fail";
            > > echo "Incorrect Username password";
            > > //header("Location: h.html");
            > > // echo $username;
            > > }
            > >
            > > if($login=="success"){
            > > header("Location: home.php");
            > > //echo "jgfuh";
            > > }
            > > ?>
            > >
            > > Please help
            > >
            > >
            > >
            >
            > --
            > Abdul Munim Kazia
            > mail@... <mail%40munimkazia.com>
            >
            > [Non-text portions of this message have been removed]
            >
            >
            >



            --


            [Non-text portions of this message have been removed]
          • janakiraman
            Hi Bhatavanti, Whenever session are used the session_start() should be at starting of the program.  So please move the session_start() to the first line.
            Message 5 of 5 , Mar 9, 2010
            • 0 Attachment
              Hi Bhatavanti,

              Whenever session are used the session_start() should be at starting of the program.  So please move the session_start() to the first line.

              Regards,
              Janakiraman.
              --- On Tue, 9/3/10, bhatavanti <bhatavanti@...> wrote:

              From: bhatavanti <bhatavanti@...>
              Subject: [bang-phpug] Warning : Headers already sent
              To: bang-phpug@yahoogroups.com
              Date: Tuesday, 9 March, 2010, 1:06 PM







               









              Hi,



              If I try to redirect a page to another page using Header(), I am getting warnings :



              Warning: session_start( ) [function.session- start]: Cannot send session cache limiter - headers already sent (output started at /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ l2.php:2) in /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ l2.php on line 16



              Warning: Cannot modify header information - headers already sent by (output started at /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ l2.php:2) in /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ l2.php on line 27



              Here is the code :



              <?PHP

              include("connect. php");

              $username = $_POST['username' ];

              $password = $_POST['password' ];

              $result=mysql_ query("select * from customerlogin where custname='$username ' AND custpassword= '$password' ");

              $rowCheck = mysql_num_rows( $result);



              //echo $rowCheck;

              if($rowCheck > 0)

              {



              // while($row = mysql_fetch_ array($result) )

              //{

              $login="success" ;

              session_start( );

              $_SESSION['loginid' ]=$username;



              } else {

              $login="fail" ;

              echo "Incorrect Username password";

              //header("Location: h.html");

              // echo $username;

              }



              if($login==" success") {

              header("Location: home.php");

              //echo "jgfuh";

              }

              ?>



              Please help























              Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! http://downloads.yahoo.com/in/internetexplorer/

              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.