Unholy Prayer Posted November 27, 2006 Share Posted November 27, 2006 Ok, I know all this other crap about databases and strings, but how do I make my links so it's only one page? Like instead of a seperate page for a members list, it would be index.php?act=memberslist or index.php?act=login etc? Quote Link to comment Share on other sites More sharing options...
fert Posted November 27, 2006 Share Posted November 27, 2006 $_GET Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted November 27, 2006 Share Posted November 27, 2006 There's many ways you can do this... - Your index.php could be a base page that includes a "memberslist" or a "login" file (You should be careful if you do something like include $_GET['act'] . '.php'; though. - You could do file_get_contents() and get the contents to echo to the user instead of the above method. - You could do it as a method of "get the 'act' from a database/template directory to display" - You could use it as a method to choose which logic path you go down to display the pageIt all boils down to using $_GET['act'] to determine the content of your page, and is in no way shape or form limited to the few things I listed above (which were a lot alike.)There's many ways you can use the "index.php" action you describe, but I couldn't see it as a great way of keeping your code clean without using template files...Doing the "index.php" thing you describe also reduces URL readability, which can be a big thing, ever had to type out a URL that's like the one this forum's on?No harm in sticking to good ol' separate files imho... Just my 2 cents, Sorry if I got too much into application as opposed to coding since this is the wrong forum for it. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted November 27, 2006 Share Posted November 27, 2006 if you want to do what you are doing and its only for a members system or something small and the links wont change much you can do something like this:[code=php:0]$idx = new Main;class Main {function Main(){ //this function will run autoif(!isset($_GET['act'])){ $act = 'login'; }else{ $act = $_GET['act']; }switch($act){case 'login':$this->login();break;//more cases in heredefault:$this->login(); //if nothing is entered go to default page, login}}function login(){echo <<<htmlThis is our login page!html;}} //end Main class[/code]classes are great! if you dont no OOP i sugegst you start learning it becasue its useful! 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.