Easily create pages like /index.php?action=home, /index.php?action=about, or any other pages you'd like. <?php // set up php get action $page = $_GET['action']; // set up php home on index.php?action=home if($page == 'home'){ // if page is home content displays echo 'This is home page'; // set up php about on index.php?action=about } elseif($page == 'about'){ // if page is about content displays echo 'This is about page'; // if page is normal.. on index.php } else { // display following content displays echo 'Some random content on main page'; // end if statement.. } ?> Code (markup): To change the /?action=home, change the first string I set up... like so: $page = $_GET['[color=red]action[/color]']; Code (markup): for all of the pages, just change each one of these: } elseif($page == '[color=red]about[/color]'){ Code (markup): I recommend including files instead of echoing text.. like this: } elseif($page == 'about'){ // if page is about content displays include('[color=red]page.php[/color]'); Code (markup):
Or simply: $function = 'display_' . $_GET['action']; if (function_exists($function)) { $function(); } function display_home() { } function display_about() { } PHP: This allows you to simply add a simple function instead of having to do the if else structure.
To iterate that (and what is an ifelse?) Something like this tends to work better. $page = isset($_REQUEST["page"])?str_replace(".", "", $_REQUEST["page"]):"home"; //the reason for the replacement of . is to prevent hack attemps like page=../../ etc if(!file_exists(realpath("pages/".$page.".php"))) { echo "Unable to load requested page"; } else { include('pages/'.$page.'.php'); } PHP: including a file is fine, but make sure you secure the input then. (and I've always prefered switch() { } statements over large blocks of if-then-else)