PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
// index.php.
if (isset($_GET['id'])) {
switch($_GET['id']) {
case 0:
echo 'Welcome to my homepage!';
break;
case 1:
echo 'My name is Foo';
break;
default:
echo 'Nope, no such page here...';
}
}
?>
<br />
<a href="index.php?id=0">Homepage</a> | <a href="index.php?id=1">I am...</a>
The 't' stands for topic, so that the viewtopic.php page knows what id to search for in the database to retrieve it's information.
'main.php?id=home' might tell the main.php page to include the home(.php/.html) page somewhere within. By doing this, you can rearrange the looks of the site at instant while having fewer files to edit.
Alright.. I use the one that JAM said. Well, so I put that on my index.php. How will I let the index.php know which files are the ones that's suppose to be id? And can't I change the id to something else?
is generally frowned upon. Having the .php there helps but without what if you did index.php?id=../etc/passwd? A better way to go about this is to create an array with all the valid names in it and check the $id against that array before including the file.