Sending user to another page ?

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

    Sending user to another page ?

    Hi guys,

    I want to do something simple, here is the code:

    <?php

    if($ageCheck)
    // goto mainpage.html
    else
    // goto under21.html

    ?>

    What is the best way to do that ? I looked at header() but I'm not sure if
    that's the best way. Thanks.

    Take care,
    Cyrus


  • Nik Coughin

    #2
    Re: Sending user to another page ?

    Cyrus D. wrote:[color=blue]
    > Hi guys,
    >
    > I want to do something simple, here is the code:
    >
    > <?php
    >
    > if($ageCheck)
    > // goto mainpage.html
    > else
    > // goto under21.html
    >[color=green]
    >>[/color]
    >
    > What is the best way to do that ? I looked at header() but I'm not
    > sure if that's the best way. Thanks.
    >
    > Take care,
    > Cyrus[/color]

    Any reason that you can't do:

    <?php

    if( $ageCheck )
    {
    include( 'mainpage.html' );
    }
    else
    {
    include( 'under21.html' );
    }

    ?>


    Comment

    • Cyrus D.

      #3
      Re: Sending user to another page ?

      Hi,

      No, I don't want to do it that way for several reasons.

      Is it so difficult to just send the user to another URL ? It should be an
      easy thing to do.

      Take care,
      Cyrus


      Comment

      • Shawn Wilson

        #4
        Re: Sending user to another page ?

        "Cyrus D." wrote:[color=blue]
        >
        > Hi,
        >
        > No, I don't want to do it that way for several reasons.
        >
        > Is it so difficult to just send the user to another URL ? It should be an
        > easy thing to do.[/color]

        Header("Locatio n: http://whatever.com/under21.php") should work fine, as long as
        you haven't outputted any text at all before the header. And you should put an
        exit() afer it.

        Shawn
        --
        Shawn Wilson
        shawn@glassgian t.com

        Comment

        • Cyrus D.

          #5
          Re: Sending user to another page ?

          Thanks man,

          The thing that was confusing me with Header() is the part about not
          outputing anything before the call.

          That just means outputing something that would show up on the page, like the
          output from 'echo' right ? I can still have functions with calculations
          before the Header() call can't I ?

          Take care,
          Cyrus


          Comment

          • 2metre

            #6
            Re: Sending user to another page ?

            Cyrus D. wrote:[color=blue]
            > No, I don't want to do it that way for several reasons.
            >
            > Is it so difficult to just send the user to another URL ? It should be an
            > easy thing to do[/color]
            No, its not difficult. The last solution given to you proves that.

            You could do yourself a big favour by explaining your needs more
            accurately (and being less dismissive of someone that's taken the time
            to gve you an extremely elegant solution.)

            Comment

            • Shawn Wilson

              #7
              Re: Sending user to another page ?

              "Cyrus D." wrote:[color=blue]
              >
              > The thing that was confusing me with Header() is the part about not
              > outputing anything before the call.
              >
              > That just means outputing something that would show up on the page, like the
              > output from 'echo' right ? I can still have functions with calculations
              > before the Header() call can't I ?[/color]

              Yup, that could be something from echo, any HTML you have in the page before the
              header, any error messages that the server produces, or even just a single blank
              line before your first <?PHP tag. Or it could be any of the above produced from
              any included or required files.

              You can do calculations as long as they produce no output or you buffer the
              output.

              Shawn
              --
              Shawn Wilson
              shawn@glassgian t.com

              Comment

              Working...