thomashw Posted January 7, 2008 Share Posted January 7, 2008 Whenever I go to a website that uses a database, the URL is something like this (the URL for a page other than index.php, I mean): http://www.website.ca/index.php?somethingid=80 The pages never seem to leave index.php, but just use a specific id (such as product, manufacturer, etc.) Is the goal to have ONE multipurpose page called index.php which contains all the html and php code for your website? Or is it okay to have seperate pages to seperate your code (and maybe make it a tad easier?) I'm completely new to this, so if this is a dumb question I apologize. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/84833-solved-multipurpose-pages/ Share on other sites More sharing options...
GingerRobot Posted January 7, 2008 Share Posted January 7, 2008 You'll actually find that most places do have lots of different pages. They use whats known as mod_rewrite to tell the webserver which page has been requested. For example, say i have a site and a link to it is: example.com/articles/10015/ I could use mod_rewrite to make that url link to: example.com/articles.php?id=10015 Now, i know you mentioned using index.php, but the same sort of thing applies. Alternative methods are to use index.php to include various other pages based on the url: <?php $page = $_GET['page']; include($page.'.php'); Or to use the parameters passed in the url to select content from the database. So, in short, no -there is nothing wrong with a more tradional approach of completely separate pages. People use the above methods for many reasons, includig easy of layout change, and search engine optimization. But unless you have a big site, then there's probably not a lot to worry about. Quote Link to comment https://forums.phpfreaks.com/topic/84833-solved-multipurpose-pages/#findComment-432506 Share on other sites More sharing options...
PC Nerd Posted January 7, 2008 Share Posted January 7, 2008 ok.... sure: index.php home.php contact.php etc will all work.. the other way to do it is like this: index.php?id=1 then in index.php: if($_GET['id'] == 1) { then do one page. usually built rhoguh : if($_GET['id'] == 1) {require('page1.inc'); } then you build your pages in page1. - but it appears to be index.php hope that helps you to understand Quote Link to comment https://forums.phpfreaks.com/topic/84833-solved-multipurpose-pages/#findComment-432510 Share on other sites More sharing options...
thomashw Posted January 7, 2008 Author Share Posted January 7, 2008 Thanks for clearing it up. Quote Link to comment https://forums.phpfreaks.com/topic/84833-solved-multipurpose-pages/#findComment-432513 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.