lewis987 Posted May 7, 2007 Share Posted May 7, 2007 this is the code i have just now <? include 'code.php' ?> //where variables are kept <? $welcome = $_REQUEST['welcome']; $leave = $_REQUEST['leave']; if ( $welcome ) echo $page['welcome']; if ( $leave ) { echo $page['leave']; { } else { echo $page['redirect']; } ?> what i want to do is, if the variable passed is "welome" i want it to show a welcome page and if "leave" is passed i want it to show a leave page, and when no variable is passed i want it to redirect to a totally different page like this: index.php?welcome Show welcome page index.php?leave show leaving page index.php redirect to a different page Link to comment https://forums.phpfreaks.com/topic/50374-solved-showing-a-different-page-when-a-variable-is-passed/ Share on other sites More sharing options...
papaface Posted May 7, 2007 Share Posted May 7, 2007 Change your code to: <?php include ("code.php"); ?> <?php $location = $_GET['location']; switch ($location) { case "welcome": echo $page['welcome']; break; case "leave": echo $page['leave']; break; default: echo $page['redirect']; } ?> example url: index.php?location=welcome Link to comment https://forums.phpfreaks.com/topic/50374-solved-showing-a-different-page-when-a-variable-is-passed/#findComment-247361 Share on other sites More sharing options...
pocobueno1388 Posted May 7, 2007 Share Posted May 7, 2007 <?php include 'code.php'; //where variables are kept if (isset($_GET['welcome'])){ echo $page['welcome']; } else if (isset($_GET['leave'])) { echo $page['leave']; } else { //redirect them with the header() function. //www.php.net/header } ?> Link to comment https://forums.phpfreaks.com/topic/50374-solved-showing-a-different-page-when-a-variable-is-passed/#findComment-247362 Share on other sites More sharing options...
lewis987 Posted May 7, 2007 Author Share Posted May 7, 2007 Both works, thanks! Link to comment https://forums.phpfreaks.com/topic/50374-solved-showing-a-different-page-when-a-variable-is-passed/#findComment-247374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.