Sending user to another page ?

This is a discussion on Sending user to another page ? within the PHP Language forums, part of the PHP Programming Forums category; Hi guys, I want to do something simple, here is the code: <?php if($ageCheck) // goto mainpage.html else // ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-19-2004
Cyrus D.
 
Posts: n/a
Default 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


Reply With Quote
  #2 (permalink)  
Old 10-19-2004
Nik Coughin
 
Posts: n/a
Default Re: Sending user to another page ?

Cyrus D. wrote:
> 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


Any reason that you can't do:

<?php

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

?>


Reply With Quote
  #3 (permalink)  
Old 10-19-2004
Cyrus D.
 
Posts: n/a
Default 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


Reply With Quote
  #4 (permalink)  
Old 10-19-2004
Shawn Wilson
 
Posts: n/a
Default Re: Sending user to another page ?

"Cyrus D." wrote:
>
> 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.


Header("Location: 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@glassgiant.com
http://www.glassgiant.com
Reply With Quote
  #5 (permalink)  
Old 10-19-2004
Cyrus D.
 
Posts: n/a
Default 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


Reply With Quote
  #6 (permalink)  
Old 10-19-2004
2metre
 
Posts: n/a
Default Re: Sending user to another page ?

Cyrus D. wrote:
> 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

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.)
Reply With Quote
  #7 (permalink)  
Old 10-19-2004
Shawn Wilson
 
Posts: n/a
Default Re: Sending user to another page ?

"Cyrus D." wrote:
>
> 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 ?


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@glassgiant.com
http://www.glassgiant.com
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:58 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0