Page 1 of 1

switch redirect problem

Posted: Tue Apr 20, 2004 3:56 pm
by speedamp
hello everybody,

i have this script, and i cannot get this to pass to the correct page. It only goes to ELSE section of the statement:

Any ideas why it won't forward correctly?

target page:
---------------------------------------------------------------------------------
<?
if (isset($_GET['page']) && $_GET['page'] != '') {

Switch ($_GET['page']) {
Case "corporate":
$url = "corporatepage";
break;

Case "usatf":
$url = "usatfpage";
Break;

Case "school":
$url = "schoopage";
Break;

Case "volunteer":
$url = "volunteerpage";
Break;

Case "youth":
$url = "youthpage";
Break;

}

Header('Location: ' . $url);

}

else {

$url = "........page that is always fowarded to";
Header('Location: ' . $url);

}

?>


-----------------------------------------------------------------------

this always goes to the ELSE page.

thanks,
-Michael

Posted: Tue Apr 20, 2004 4:03 pm
by feyd
first, before a mod slaps you read this

looks like $_GET['page'] either isn't set properly or is empty.. can you post the code that leads into this?

Posted: Tue Apr 20, 2004 4:23 pm
by John Cartwright
a better way to check it its set or empty is

Code: Select all

<?php
if (!empty($_GET['page'])) {
?>
empty checks to see if it is even set, if not the statement fail and it also checks to see if the value of NULL, and if so it will fail .. because we have made the empty inversed.

Try echo'ing your variables to see if they are being set.

ie echo $_GET['page']; at the bottom of your page.