Jump to content

Help with PHP include from address


jackinthebox11

Recommended Posts

Hi,

I am trying to make a little script here.

This is what I have so far:

 

index.php

<?php

include("$page.html")

?>

 

So when you type something in the address bar like:

"site.com/index.php?page=downloads"

The page will display the downloads.html.

 

That parts fine. But what I want to know is how can I restrict the pages that this allows? Like only let "downloads, home, and contact us" pages be available?

 

Any and all help appreciated,

Thanks

-Jack

Link to comment
https://forums.phpfreaks.com/topic/150832-help-with-php-include-from-address/
Share on other sites

sore the information on the pages in a database and then reference them by id instead of name that way the user will only see the id of the page being displayed, take a look at this it works in the way im explaining

 

http://www.gming-network.ath.cx/phpcms/

include_once('page/'.(isset($_GET['page']) AND ctype_alnum($_GET['page']) AND file_exsists('pages/'.$_GET['page'].'.php') AND in_array($_GET['page'],array('downloads','home','contactus')) ?$_GET['page']:'index').'.php');

Not perfect but its a start.

 

 

switch ($_REQUEST['page']) {
  case 'games':$pagefile='games.php';break;
  case 'demos':$pagefile='demos.php';break;
  case 'contact':$pagefile='contact.php';break;
  default:$pagefile='index.php';
}

 

That will only let the chosen ones through - anything else and index.php is used.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.