Page 1 of 1
Help with a Hyperlink
Posted: Tue Mar 21, 2006 4:33 am
by silent_assassin
I have the following code used
Code: Select all
<?PHP
switch ($_GET[page]){
case "home":
include 'index.php';
break;
case "console":
include 'console.php';
}
?>
and a hyperlink of
Code: Select all
<a href="index.php?page=console">Click Here to Get to the Console</a>
When I click the link it takes me to console.php but then it also shows the contents on index.php below the contents of console.php.
What am I doing wrong
P.S. It still does it when i remove the include index.php line out
Posted: Tue Mar 21, 2006 4:39 am
by s.dot
is that the entire contents of that page?
switch($_GET[page]) should be switch($_GET['page']) .. but I'm not sure that matters.. i dunno
Posted: Tue Mar 21, 2006 4:42 am
by Maugrim_The_Reaper
Code: Select all
switch($_GET['page'])
{
case 'home':
include 'index.php';
break;
case 'console':
include 'console.php';
break;
default:
include 'index.php';
}
Try this for starters. Then check if any includes, are including other files in your switch statement. Where is the switch by the way? In all files, or just a few?
Posted: Tue Mar 21, 2006 4:42 am
by silent_assassin
nah that don't matter it still does it even if its 'page' or page
Posted: Tue Mar 21, 2006 4:53 am
by silent_assassin
the switch is in the index.php file...the console.php as sweet fa in apart from 1 line of text just to test it.
When i put the
in then it just screws up and the index page don't load at all
Posted: Tue Mar 21, 2006 4:59 am
by Maugrim_The_Reaper
index would only be a default in pages other than index.php - in fact index.php probably shouldn't even have the index.php case full stop - double inclusions?
You go to index.php?page=home. You are now at index.php, with the switch re-including the same page???
You should try placing all page includes into a separate directory, then using index.php simply as a single point of entry. Then have a switch statement in index.php which contains include 'home.php' rather than index.php, with th default set to home.php.
Might work that way.
Posted: Tue Mar 21, 2006 6:49 am
by silent_assassin
I am not trying to go to index.php?page=home i am trying to access index.php?page=home, so I am trying to load another page called console.php But it still appears with the contents of index.php below it.
Posted: Tue Mar 21, 2006 2:24 pm
by eyespark
Code: Select all
if (isset($_GET['page']) && $_GET['page']) == "console"){
include 'console.php';
} else {your index page}
Posted: Tue Mar 21, 2006 2:45 pm
by John Cartwright
Have a look over at our
Useful Posts Thread