LHBraun Posted August 19, 2006 Share Posted August 19, 2006 Hello everybody - here is a PHP freshman in need of help :)I am getting some data from a MySQL database and depending of the value of one of the variables I want to sent the user to one of 2 different URLs...For example:if $row["var"]=0 then send user to http://www.mydomain.com/page1.phpif $row["var"]=1 then send user to http://www.mydomain.com/page2.phpI just cannot find out how to do this - I assume I need to do it in the php part of the code?Any help is much appreciated ??? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted August 19, 2006 Share Posted August 19, 2006 You're looking for the header() function. http://www.php.net/headerKen Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 19, 2006 Share Posted August 19, 2006 you want to use an if statement, yesyou can do this several waysif($row["var"] == 0){header("Location: http://www.example.com/page1.php");}if($row["var"] == 1){header("Location: http://www.example.com/page2.php");}ORswitch($row["var"]){case "0":header("Location: http://www.example.com/page1.php");break;case "1":header("Location: http://www.example.com/page2.php");break;default://do something else}Either way you need to have ob_start on line 1<?php ob_start(); ?> Quote Link to comment Share on other sites More sharing options...
LHBraun Posted August 20, 2006 Author Share Posted August 20, 2006 Thanks - super duper help ;D It works perfectly :-* Quote Link to comment Share on other sites More sharing options...
slipperyfish Posted August 20, 2006 Share Posted August 20, 2006 what's ob_start() ??? Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 20, 2006 Share Posted August 20, 2006 I am sure you have heard of php.nethttp://es2.php.net/manual/en/function.ob-start.phpBasicly, turns on Output Buffering (OB)This allows you to send HTM headers mid way through a php script Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.