/index.php?page=
Moderator: General Moderators
/index.php?page=
I've searched and searched, but no matter where i look i can't find an answer. How do i make it so that i can go to /index.php?page= and get the page. I am sorry if this is really beginner, but i cannot find an answer. Thank you for your time ^^.
-
hayson1991
- Forum Newbie
- Posts: 14
- Joined: Thu Mar 20, 2008 1:19 pm
Re: /index.php?page=
Use this as your index.php if you want the url to stay as /index.php?page=Asnom wrote:I've searched and searched, but no matter where i look i can't find an answer. How do i make it so that i can go to /index.php?page= and get the page. I am sorry if this is really beginner, but i cannot find an answer. Thank you for your time ^^.
Code: Select all
<?php
include $_GET['page'].'.php';
?>
Code: Select all
<?php
header('Location: '.$_GET['page']);
?>
- andym01480
- Forum Contributor
- Posts: 390
- Joined: Wed Apr 19, 2006 5:01 pm
Re: /index.php?page=
Although the previous post answers the question. Using include on user entered stuff is pretty dangerous!
Using a switch statement to check the page variable and then acting on expected entries and having a default to cover people being naughty is safer.
Using a switch statement to check the page variable and then acting on expected entries and having a default to cover people being naughty is safer.
Code: Select all
<?php
switch ($_REQUEST['page'])
{
case 1:
include("page1.php");
break;
case 2:
include("page2.php");
break;
case 3:
include("page3.php");
break;
default:
include("page1.php");
break;
}