depojones Posted July 7, 2009 Share Posted July 7, 2009 Thank you for clicking on my question. I was wondering if anyone can teach me how to create links like this in php hxxp://www.domain.com/index.php?page=home hxxp://www.domain.com/index.php?page=contact hxxp://www.domain.com/index.php?page=terms and what are the disadvantages. Thanks in advance Link to comment https://forums.phpfreaks.com/topic/165115-_getpage-problem/ Share on other sites More sharing options...
shergold Posted July 7, 2009 Share Posted July 7, 2009 here $page = $_GET ; if ($page == "index") include ("index.php") elseif ($page =="contact") include ("contact.php") do this for as many pages as you need, put this code in all of the files you want to link to and your index file. when you hyperlink use the following: <a href="/?page=pagename>pagename</a> Hope this helps, Shergold. Link to comment https://forums.phpfreaks.com/topic/165115-_getpage-problem/#findComment-870651 Share on other sites More sharing options...
p2grace Posted July 7, 2009 Share Posted July 7, 2009 I'd recommend wrapping that code in a class or a separate includes file, that way you only have to include one file, or call one class. Now if you ever need to add new include files, you don't have to update every file Link to comment https://forums.phpfreaks.com/topic/165115-_getpage-problem/#findComment-870653 Share on other sites More sharing options...
shergold Posted July 7, 2009 Share Posted July 7, 2009 good idea Link to comment https://forums.phpfreaks.com/topic/165115-_getpage-problem/#findComment-870654 Share on other sites More sharing options...
depojones Posted July 7, 2009 Author Share Posted July 7, 2009 Thank you guys. I will also make sure I protect it from RFI. Regards Link to comment https://forums.phpfreaks.com/topic/165115-_getpage-problem/#findComment-870657 Share on other sites More sharing options...
niwa3836 Posted July 8, 2009 Share Posted July 8, 2009 Also i would do if(isset($_GET['page]')) $page = $_GET['page'] ; otherwise you will start clocking up errors when page isnt added to the URL ...just nice house keeping. Link to comment https://forums.phpfreaks.com/topic/165115-_getpage-problem/#findComment-871179 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.