FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


navigation system probs





riyadh
i wrote a script which enables me to link to other pages using the index.php page like this index.php?page=privacy. but there seems to be a problem. when i load this url, the privacy page does come up but after the page finishes loading, index.php also loads under it. this is the code for the script:
Code:

<?php
switch($_GET['page'])
{
case 'forum': include('forum/index.php'); break;
case 'ul': include('upload.php'); break;
case 'dl': include('downloads.php'); break;
case 'about': include('about.php'); break;
case 'advertise': include('advertise.php'); break;
case 'contact': include('contact.php'); break;
case 'privacy': include('privacy.php'); break;
case 'request': include('request.php'); break;
case 'sitemap': include('sitemap.php'); break;
default: include('index.php'); break;
}
?>


what can i do to stop this from happening? is it because i saved this script in an external file as nav.php and in the index.php page i wrote <?php include('nav.php')?> and then wrote the code for the page in html?
sonam
I am not sure am I good understand you question (my poor english), but I thing problem is not in <?php include('nav.php')?> function. I thing problem is in includes in switch function. This switch statment give command to include other page before index.php. Break in this command will not stop index.php to loading. It is stop only switch function. Maybe you can try to change your code in this way:

Code:
<?php
switch($_GET['page'])
{
case 'forum': header("Location:forum/index.php"); break;
case 'ul': header("Location:upload.php"); break;
...

}
?>


Sonam
riyadh
i tried out what u said but this enables the user to see the real fine name which i don't want to show which is why i made script. is there any other way to do this so tht users can't see the real file name?
Stubru Freak
Yes, move everything in index.php except the nav include to a file called home.php, then change this line:
Code:
default: include('index.php'); break;

to
Code:
default: include('home.php'); break;
hexkid
riyadh wrote:
i wrote a script which enables me to link to other pages using the index.php page like this index.php?page=privacy. but there seems to be a problem. when i load this url, the privacy page does come up but after the page finishes loading, index.php also loads under it. this is the code for the script:
Code:

<?php
switch($_GET['page'])
{
case 'forum': include('forum/index.php'); break;
case 'ul': include('upload.php'); break;
// ...
?>


what can i do to stop this from happening?


Replace the breaks with exits.
Code:
<?php
switch($_GET['page'])
{
case 'forum': include('forum/index.php'); exit;
case 'ul': include('upload.php'); exit;
// ...
Related topics
Brett Tabke's website tutorial
Simple PHP Navigation
Frankfurt Motor Show, 2005
website in flash
PVPMachine - Paintball, Video Games, PC
The Hangout
Rules to Make Your Site Annoying
Apple Patents Speaking iPod
Media Player 11 beta
GPS on, Brain off
Billy the Monkey- BM Homepage, what do you think?
WEb page good design
Do you prefer Flash sites Or Plain?
Meizu Music Card----such a cool mp3 player
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.