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 Quote Link to comment 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'); Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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. 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.