PDA

View Full Version : Variables from URL problems,



chunkeymonkey
December 24th, 2006, 10:48 PM
Hello,

I'm just trying to do the simple, if the url is ?page=hello get the page hello, type thing... and for some reason, I just can't seem to work out why this doesn't seem to work:



$requestedpage = $_GET['go'];
$actualpage = ("/php/".$requestedpage.".php");
$defaultpage = ("/php/welcome.php");

if (isset($requestedpage)) {
If (file_exists($actualpage)) {
require_once($actualpage);
} else {
require_once ($defaultpage);
}

When ever I go to test it, I get an error spat out at me at line 10 (happens to be the beginning of the If statement line).

Any Ideas?

... Much appreciated :)

chunkeymonkey
December 24th, 2006, 11:07 PM
Oh, I seemed to have got it... if anyone wanted to know the answer, or was stuck in the same boat as me- I just tried another way of writing it;


if (isset($_GET['go'])) {
$requestedpage = ($_GET['go']);
}

$actualpage = ("/php/".$requestedpage.".php");
$defaultpage = ("/php/welcome.php");

if (file_exists($actualpage)) {
require_once($acutalpage);
} else {
require_once($defaultpage);
}