Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Llanilek

Llanilek Avatar
Former Elite Mod

****
Dedicated Studio Member

931


October 2005
This way of getting the ?page url is slightly longer than the others, but in some sense is more secure as you don't get nasty warnings if you type in the wrong page.


<?

$page = $_GET['page']; // tells the server to get the page typed in and show the contents of that in the browser

  switch ( $page ) {
  case 'home': // tells the server that home is a correct page
  include "main.php"; // includes the main.php when the user types ?page=home in the url
  break; // escapes the script if the url is the case above

  case 'pagename':
  include "filename.php";
  break;

  default: // sets the default page
  include "main.php"; // if no url is type in with the case extenstion then it will automatically send you to main.php
  break;

// The default setting is also where if an error is returned normally (if the page doesn't exist) then it takes you back to main.php
}
?>


hope this helps some of you guys



Last Edit: Oct 3, 2005 15:21:35 GMT by Llanilek

Eric

Eric Avatar



1,442


November 2005
Should your pages all be something like:
?page=main
and the file associated with it be "main.php"

and
?page=about
and the associated file with it is "about.php"

You can do:
$page = $_GET['page']
$ok_pages = array("main","about","etc");

if(in_array($page, $ok_pages))
{
   require_once($page . ".php");
}



Just thought I'd share that, but in all other cases, yeah your way is the best.

newBookmarkLockedFalling