Mortalis9
Nov 4 2007, 06:20 AM
how do i do this? i found it a while back but i don't remember where it was.
thanks.
Earpy
Nov 4 2007, 02:27 PM
I have posted a similar question which can be found
here That's the only help I can give afraid
drakkar
Nov 4 2007, 03:35 PM
.../page.php?=aaaaa
Then $_SERVER["QUERY_STRING"] contains "=aaaaa".
Ignore .php is an Apache config command, i dont know if this server has it on.
Snarup
Nov 7 2007, 08:32 PM
<?php
$variable = $_GET['variable'];
switch($variable) {
default: include('home.php'); break;
case "forum": include('forum.php'); break;
}
?>
Basically the first thing I've done is set a variable to retrieve the information on the other side of the equal sign, by that I mean I am getting the "membercp" out of "www.yoursite.com/index.php?to=membercp". As you can tell my variable used is "to", you can change that to whatever you like by editing the line of code, "$variable = $_GET['variable'];" to "$variable = $_GET['WHATEVER'];".
The switch statement is used to change the output depending on the information on the other side of the equal sign, as you can see there is a "default" and a case of "forum". Simply put, if I were to used the same example as above, when the information comes back as none, the default block of code runs, if the information is "forum" than the block of code relevant to it runs.
I hope this helps, feel free to ask anything you don't understand and I will try to answer you.
Colin
Nov 7 2007, 10:53 PM
Exo
Nov 11 2007, 09:29 PM
this should help
CODE
<?php
if(!isset($_GET['id'])) {
include "homepage.php";
}elseif(!file_exists($_GET['id'].".php")) { // this also takes you to the home page if the page you're looking for using the ?page= dosn't exist
include "404.php";
}else{ //if all goes well
include $_GET['id'].".php"; // include the page e.g if it was ?page=tutorials include tutorials.php
} ;?>
MrTouz
Nov 14 2007, 01:08 AM
Colin on your tutorial you should add a function in case the page doesnt exist...
Erind
Nov 17 2007, 11:20 PM
Colin, your tutorial has many mistakes and it isn't much help to the reader.
I usually leave the extensions out. Since my pages are pretty much all .php, I just use the name and add .php in the include function.
MrTouz
Nov 19 2007, 09:51 PM
someone posted a function where no matter which extension you typed it'll always return the one you asked. lets say you type home.html or home.php or home.so well it'll always return to the home page... if the page was a php than it will always return to the home.php... pretty nice !
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.