joecooper Posted May 5, 2008 Share Posted May 5, 2008 the page will be accessed like this: index.php?module=login and i have this code to load the corosponding page: include("$module.php"); but it doesnt include anything. and doing echo("$module"); doesnt return anything Link to comment https://forums.phpfreaks.com/topic/104282-setting-varibles-in-the-url/ Share on other sites More sharing options...
pocobueno1388 Posted May 5, 2008 Share Posted May 5, 2008 You would do it like this: include($_GET['module'].".php"); This isn't the safest thing to do. Make sure you do a check on the file they put in the URL and make sure you want them to have access to it. Link to comment https://forums.phpfreaks.com/topic/104282-setting-varibles-in-the-url/#findComment-533905 Share on other sites More sharing options...
DarkWater Posted May 5, 2008 Share Posted May 5, 2008 $module = $_GET['module'] >_> AND DO SOME CHECKING. Make sure they only include modules that YOU allow. Make an array of modules and use in_array. Link to comment https://forums.phpfreaks.com/topic/104282-setting-varibles-in-the-url/#findComment-533906 Share on other sites More sharing options...
peranha Posted May 5, 2008 Share Posted May 5, 2008 you need $module = $_GET['module']; Link to comment https://forums.phpfreaks.com/topic/104282-setting-varibles-in-the-url/#findComment-533907 Share on other sites More sharing options...
trq Posted May 5, 2008 Share Posted May 5, 2008 You don't define $module anywhere. It would be..... $_GET['module']. Having said that, it is extremely insecure to simply include files in such a manor. At the very least, try... <?php if (isset($_GET['module'])) { if (file_exists($_GET['module'] . '.php')) { include $_GET['module'] . '.php'; } } ?> Link to comment https://forums.phpfreaks.com/topic/104282-setting-varibles-in-the-url/#findComment-533911 Share on other sites More sharing options...
DarkWater Posted May 5, 2008 Share Posted May 5, 2008 Still not secure....He needs some security. Link to comment https://forums.phpfreaks.com/topic/104282-setting-varibles-in-the-url/#findComment-533916 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.