Ok, so, many of you have seen things like index.php?id=1 or index.php?id=1&type=blah on websites. Here is how we designers do it.
For something with one variable, like index.php?id=1, use the following code. Place this code as your entire index.php (NOTE - It HAS to be index.php, .html will do you no good).
You can put as many elseifs in there as you like. I hope this helps some of you.
09-14-2005, 01:57 PM
Illegalx17
Yea, i know this. Isn't it better to use the $POST[] to pass variables to page from page though?
09-14-2005, 04:14 PM
weasel
It is, but this isnt passing variables. My code is all you should have in index.php. It then $_GETs other pages, not other variables. All the variables are on that one page, so there is no need for $_POST. If you were making a login script that used multiple pages or something like it, then you need $_POST.
09-14-2005, 04:17 PM
Illegalx17
I mean passing the variables for each page. For example, the way you would do that is by makinga link to http://page.com?id=1 and that would pass the variable, but it would make the URLs cleaner if you just used a POST statement then to decide the include you would get the post.
09-14-2005, 04:51 PM
weasel
Really, $_GET works fine. I dunno what else you would have to change if you switched it to $_POST. My script really does the job in a clean manner, but you are welcome to use $_POST.
09-14-2005, 07:52 PM
weasel
Sorry for the double post.
Actually, you cannot use $_POST because that sends variables. You are getting variables. index.php?id=1. You are GETTING the id, not posting it. So you have to use $_GET in this case.