Jump to content

[SOLVED] Mental relapse over ?content=


bladechob

Recommended Posts

Bit embarrassing this! I've forgotten a basic and need my memory jogging. I'm using index1.phpcontent=page on a site and can't for the life of me remember what to stick in the index page to call a page into the content area - in this case home.php. Currently have got

]<?php require_once($_GET['content']).'.php';?> 

which is fine for clicking the nav buttons and displaying the appropriate pages, but I'm stuffed with the home page! Have tried

<? if(empty($_GET['content'])||$_GET['content']=='home'){

?> 

but this just brings back blank. Help!!!

Link to comment
https://forums.phpfreaks.com/topic/57938-solved-mental-relapse-over-content/
Share on other sites

Simply including files this way without first checking they are valid is VERY insecure. Try...

 

<?php

 if (isset($_GET['content']) || $_GET['content']== 'home') {
   // put valid files within the $safe array.
   $safe = array('about','links','foo');
   if (in_array($_GET['content'],$safe)) {
     include $_GET['content'].'.php';
   }
 } else {
   include 'home.php';
 }

?>

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.