tobimichigan Posted July 28, 2009 Share Posted July 28, 2009 Hi Code Gurus, Please could you folks kindly give me a lead on creating multiple action pages including restricted pages from a single page ? For example: index.php?action=login Thanks a bunch Link to comment https://forums.phpfreaks.com/topic/167779-url-parameterizing/ Share on other sites More sharing options...
waynew Posted July 28, 2009 Share Posted July 28, 2009 //setup array of allowed actions $actions = array("login","logout","etc"); $action = "index"; //set it to index by default //if action exists and is an allowed action, take it in if(isset($_GET['action']) && in_array($_GET['action'],$actions)){ $action= $_GET['action']; } //have a folder called actions with login.php and logout.php etc that control the processes behind those processes require_once('actions/'.$action.'.php'); Link to comment https://forums.phpfreaks.com/topic/167779-url-parameterizing/#findComment-884766 Share on other sites More sharing options...
tobimichigan Posted July 28, 2009 Author Share Posted July 28, 2009 //setup array of allowed actions $actions = array("login","logout","etc"); $action = "index"; //set it to index by default //if action exists and is an allowed action, take it in if(isset($_GET['action']) && in_array($_GET['action'],$actions)){ $action= $_GET['action']; } //have a folder called actions with login.php and logout.php etc that control the processes behind those processes require_once('actions/'.$action.'.php'); Wayne, thanks for your reply..but wait a minute, where would all these code go? On a sepearte php page, or on the same folder as the variable pages login, logout etc? Link to comment https://forums.phpfreaks.com/topic/167779-url-parameterizing/#findComment-884787 Share on other sites More sharing options...
patrickmvi Posted July 28, 2009 Share Posted July 28, 2009 It's really up to you how you want to arrange it but normally it would go in your index.php script. Link to comment https://forums.phpfreaks.com/topic/167779-url-parameterizing/#findComment-884789 Share on other sites More sharing options...
aschk Posted July 28, 2009 Share Posted July 28, 2009 Firstly you probably want a rewrite rule to force all page requests through index.php Secondly you'll want your index.php to decide what actions it's called based on the URL that has been sent through. Link to comment https://forums.phpfreaks.com/topic/167779-url-parameterizing/#findComment-884819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.