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

Re: [phpXperts] ***Conditional header redirection

Expand Messages
  • Ashraf Jahan
    Dear Mr.Saiful, U will try : ob_start() function. start of the page. May b this will help for u. Best luck. Thank s Md. Ashraf Jahan. Php programmer A.N.M.
    Message 1 of 7 , Apr 1, 2008
    • 0 Attachment
      Dear Mr.Saiful,
       
      U will try :
      ob_start() function. start of the page. May b this will help for u.
       
      Best luck.
       
      Thank's
      Md. Ashraf Jahan.
      Php programmer

      "A.N.M. Saiful Islam" <email@...> wrote:
      Dear all Xperts,
      I want to use a conditional header redirection.
      The explanation is like bellow:
      <?php
      include_once “header.inc”
      if( CONDITION == TRUE )
      {
                echo “RESULT”;
      }
      else
      {
      if( CONDITION == TRUE )
      {
                          header( “Location: somewhere.php” );
                          echo “If your browser does not support redirection <a href=’continue. php’>click here</a> to continue.”;
      }
      else
      {
                          DO ANOTHER ACTION
      }
      }
      ?>
      Now how could I avoide the Cannot modify header information - headers already sent error?
      Could not I use the header function for redirection if anything sent before calling function?
      Is there any method to clear the header’s garbage.
      Like as:
      clear_header_ garbage(); //clear_header_ garbage is a sample function name. I am searching for such function
      header( “Location: somewhere.php” );
      @Saiful

      You rock. That's why Blockbuster' s offering you one month of Blockbuster Total Access, No Cost.


      You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.

    • Muktadir Hossain
      Hello Saiful, Some output is send to the browser prior to the code at line 10. I guess, header.inc is causing this. You can use ob_start() to avoid sending
      Message 2 of 7 , Apr 1, 2008
      • 0 Attachment
        Hello Saiful,

        Some output is send to the browser prior to the code at line 10. I guess, header.inc is causing this.

        You can use ob_start() to avoid sending headers prior to your intended header.

        Thanks,
        Muktadir Hossain

        "A.N.M. Saiful Islam" <email@...> wrote:
        Dear all Xperts,
         
        I want to use a conditional header redirection.
         
        The explanation is like bellow:
         
        <?php
         
        include_once “header.inc”
         
        if( CONDITION == TRUE )
        {
                  echo “RESULT”;
        }
        else
        {
        if( CONDITION == TRUE )
        {
                            header( “Location: somewhere.php” );
                            echo “If your browser does not support redirection <a href=’continue. php’>click here</a> to continue.”;
        }
        else
        {
                            DO ANOTHER ACTION
        }
        }
         
        ?>
         
        Now how could I avoide the Cannot modify header information - headers already sent error?
         
        Could not I use the header function for redirection if anything sent before calling function?
         
        Is there any method to clear the header’s garbage.
         
        Like as:
         
        clear_header_ garbage(); //clear_header_ garbage is a sample function name. I am searching for such function
        header( “Location: somewhere.php” );
         
        @Saiful

        You rock. That's why Blockbuster' s offering you one month of Blockbuster Total Access, No Cost.


        You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.

      • Muthukumar Selvarasu
        Hi, Use @ first line of your code. Thanks, Muthukumar Selvarasu, Project Manager (Web Development), Webmasters Ltd. From:
        Message 3 of 7 , Apr 1, 2008
        • 0 Attachment

          Hi,

           

          Use

           

          <? ob_start(); ?>  

           

          @ first line of your code.

           

           

           

          Thanks,

          Muthukumar Selvarasu,

          Project Manager (Web Development),

          Webmasters Ltd.

           

           

          From: phpexperts@yahoogroups.com [mailto:phpexperts@yahoogroups.com] On Behalf Of A.N.M. Saiful Islam
          Sent: Wednesday, April 02, 2008 4:43 AM
          To: php experts; iiuc porgrammers
          Subject: [phpXperts] ***Conditional header redirection

           

          Dear all Xperts,

           

          I want to use a conditional header redirection.

           

          The explanation is like bellow:

           

          <?php

           

          include_once “header.inc”

           

          if( CONDITION == TRUE )

          {

                    echo “RESULT”;

          }

          else

          {

          if( CONDITION == TRUE )

          {

                              header( “Location: somewhere.php” );

                              echo “If your browser does not support redirection <a href=’continue.php’>click here</a> to continue.”;

          }

          else

          {

                              DO ANOTHER ACTION

          }

          }

           

          ?>

           

          Now how could I avoide the Cannot modify header information - headers already sent error?

           

          Could not I use the header function for redirection if anything sent before calling function?

           

          Is there any method to clear the header’s garbage.

           

          Like as:

           

          clear_header_garbage(); //clear_header_garbage is a sample function name. I am searching for such function

          header( “Location: somewhere.php” );

           

          @Saiful

           


          You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.

        • Aman (আমান)
          use output buffering till header redirections. such as: *
          Message 4 of 7 , Apr 1, 2008
          • 0 Attachment
            use output buffering till header redirections. such as:

            <?php
             
            ob_start(); // ADD HERE

            include_once
            "header.inc"
             
            if( CONDITION == TRUE )
            {
                      echo "RESULT";
            }
            else
            {
            if( CONDITION == TRUE )
            {
                            ob_clean(); // and ADD HERE  
            header( "Location: somewhere.php" );


            hope that will help you
            --
            Shaikh Sonny Aman
            Trippert Labs
            www.mailtoaman.com

            Mobile : +8801556368534
            Fixed Phone: +88028915711
          • shiplu
            Hello Debug it correctly. Here is a good solution. *
            Message 5 of 7 , Apr 2, 2008
            • 0 Attachment
              Hello Debug it correctly.
              Here is a good solution.
              <?php
               
              include_once "header.inc"
               
              if( CONDITION == TRUE )
              {
                        echo "RESULT";
              }
              else
              {
              if( CONDITION == TRUE )
              {
                                  ?>
              <script type="text/javascript">
              <!--
              window.setTimeout(function(){window.location.href="somepath.php";},5000);
              //-->
              </script>
              <?php
                                  echo "If your browser does not redirect in 5 seconds <a href='continue.php'>click here</a> to continue.";
              }
              else
              {
                                  DO ANOTHER ACTION
              }
              }
               
              ?>


              --
              Shiplu
              http://talk.cmyweb.net/

            Your message has been successfully submitted and would be delivered to recipients shortly.