Help - Search - Members - Calendar
Full Version: Making Links Like Index?=members
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
Mortalis9
how do i do this? i found it a while back but i don't remember where it was.

thanks. smile.gif
Earpy
I have posted a similar question which can be found here That's the only help I can give afraid unsure.gif
drakkar
.../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
<?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
My tutorial on it smile.gif
http://colinsmiley.net/forum/viewtopic.php?t=41
Exo
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
Colin on your tutorial you should add a function in case the page doesnt exist...
Erind
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
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.
Invision Power Board © 2001-2012 Invision Power Services, Inc.