violetradio Posted March 24, 2009 Share Posted March 24, 2009 Hello guys, My PHP knowledge is little so please bare with me I have created a site to use this code <?php if($page) include("$page.php"); else include("inc_home.php"); ?> But recently it started failing. I contacted my web host and they told me that function is now disabled on there servers, but alternatively I could utilise the GET function instead. I had a play around but couldn't quite figure it. Could someone please edit that bit of code to use GET rather than include? Much appreciated, Tom Quote Link to comment Share on other sites More sharing options...
POG1 Posted March 24, 2009 Share Posted March 24, 2009 You can set it in the URL. For example index.php?page=home would set $_GET['home'] to the value of 'home' To use it in your page it is very simple. $page = isset($_GET['page']) AND ctype_alnum($_GET['page']) ? $_GET['page'] : 'inc_home'; include($page.'.php'); Quote Link to comment Share on other sites More sharing options...
Yesideez Posted March 24, 2009 Share Posted March 24, 2009 VERY DANGEROUS! This will enable anyone to run any php file on the web server. Best use a switch() instead to check for valid files being passed in the URL! Quote Link to comment Share on other sites More sharing options...
POG1 Posted March 24, 2009 Share Posted March 24, 2009 file_exsists & in_array functions would help to only allow what you want. 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.