Jump to content
xisto Community
Sign in to follow this  
sydney28th

Index.php=blah Thingy .. ?

Recommended Posts

<?phpswitch($_GET['page']) {   case "contact":      include("contact.php");   break;   default:      include("home.php");}?>

The default page is home.php, the contact page is contact.php. Add as many as you like, and then save the above code as index.php. To link to the pages - index.php?page=contact. Hope that helped, Ol.

Share this post


Link to post
Share on other sites

Chilipie did it 100% correct.

But as this is a serious issue and I've seen this done in the web, I'd like to warn you.

If you look at the code of the switch structure you can easily come up with an easier way to do it. Why to use switch when you could simply just send the page name as a get and include file based on the name.

Like this

include($_GET['page'].".php");


This works, but what if some one requests... http://yourserver.com/rg-erdr.php?_rpo=t


So ALWAYS use a switch structure OR if include a file depending on GET parameter use a list for allowed files and check on every include.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.