bladechob Posted July 1, 2007 Share Posted July 1, 2007 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!!! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 1, 2007 Share Posted July 1, 2007 if(isset($_GET['content'])) { include $_SERVER['DOCUMENT_ROOT'] . '/' . $_GET['content'] . '.php'; } else { // display home page here } Quote Link to comment Share on other sites More sharing options...
trq Posted July 1, 2007 Share Posted July 1, 2007 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'; } ?> Quote Link to comment Share on other sites More sharing options...
bladechob Posted July 1, 2007 Author Share Posted July 1, 2007 muchos gracias chaps - case solved thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.