Redirecting

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ChadEPop
Forum Newbie
Posts: 1
Joined: Wed Oct 30, 2002 11:56 am

Redirecting

Post by ChadEPop »

Hi All,
I am a PHP newbie. For years I've been working with Microsoft technology. I'm currently working on a web app using PHP and MySQL. I'm quite embarrassed to say that I can't figure out how to redirect to other url's based. I've seen the Header() function but that only works at load time. I need to find something that works like the Redirect method of the Response object in ASP. That way, I can redirect users to different url's depending on what parameters are passed.

Thanks for helping out the new guy,
Chad
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

<?php
switch ($_POSTї'mode'])
{
case 'eat':
   header('Location /eat.php');
   break;
case 'drink':
   header('Location /drink.php');
   break;
default:
   echo 'what?';
}?>
sinewave
Forum Commoner
Posts: 41
Joined: Tue Sep 10, 2002 4:35 pm
Location: Canada

Post by sinewave »

I think he would like a way of redirecting after some output. As far as i know this cannot be done with php.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

like processing half of the page and then giving control to another script?
with ob_start() and include() this can be be (almost) done.
Apache sub-requests are also nice.
Post Reply