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
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';
 }

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.