Executing another PHP page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adriann
    New Member
    • Aug 2006
    • 25

    Executing another PHP page

    Hi,
    I have a section of code, whereby after satisfying certain conditions of variables,
    I would like PHP to leave it's current page, and launch a different PHP page.

    Sort of like if a user had clicked on a Link or a submit button.

    thank you.
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    As in:

    [PHP]
    if (condition == 'met')
    header('Locatio n: new_page.php');
    else {
    // do whatever you need to do here
    }
    [/PHP]

    Ronald :cool:

    Comment

    • adriann
      New Member
      • Aug 2006
      • 25

      #3
      Hi Ronald,

      I tried yr code suggestion but I got the old "headers already sent " error message.

      Warning: Cannot modify header information - headers already sent by... blah blah blah.

      Are there any other ways to perform this task?

      thank you.

      Comment

      • phpmaet
        New Member
        • Sep 2006
        • 27

        #4
        Hi,

        This is another way for skip the current page.

        [PHP]if($_POST($cond ))
        {
        echo '<meta http-equiv=refresh content=0;url=h ome.php>';
        }[/PHP]

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          or alternitively

          [php]
          if (condition == 'met')
          require_once('n ew_page.php');
          else {
          // do whatever you need to do here
          }

          [/php]

          Comment

          • mtcyber
            New Member
            • Sep 2006
            • 1

            #6
            For uses

            header('Locatio n: new_page.php');

            You can uses ob_start(); and ob_end_flush();

            Example::

            <?
            ob_start();

            .....
            .....
            if ($condition1)
            {
            header('Locatio n: new_page1.php') ;
            }
            .....
            .....
            .....
            if ($condition1)
            {
            header('Locatio n: new_page1.php') ;
            }

            ob_end_flush();

            ?>


            =============== ======

            Originally posted by adriann
            Hi Ronald,

            I tried yr code suggestion but I got the old "headers already sent " error message.

            Warning: Cannot modify header information - headers already sent by... blah blah blah.

            Are there any other ways to perform this task?

            thank you.

            Comment

            • skim
              New Member
              • Sep 2006
              • 9

              #7
              using JS. This is the easiest way.

              <?php
              whatever your code...
              if( whatever condition){
              ?>
              <SCRIPT LANGUAGE ="JavaScript ">
              window.location = "./your/file.php"
              </SCRIPT>
              <?php
              }

              Whatever yourcode....
              ?>
              Done.

              Comment

              Working...