
June 8th, 2003
08:21 PM
with Mr. Jones
Status: Offline!
maybe
<?php
switch( $HTTP_GET_VARS['what'] ) {
case 'contact' :
include 'contact/index.php';
break;
default:
include 'main.php';
break;
}
?>
Not sure if I got the path correct though - I dont know if you need contact folder
___________________
http://www.philbrodeur.com - Expert PHP Development and Tutorials

June 15th, 2003
11:59 PM
with Mr. Jones
Status: Offline!
Updated - fixed $1337 and the register_globals inconsistence Jeb pointed out, and added the following section.
---
Now, you may ask - what about index.php?news / index.php?portfolio means of navigation? This actually isn't that hard. You see, when you go to index.php?variable, variable is initialized but not given a value. That means you can do this:
Way one, if you intend to have other query string variables besides just ?page
<?php
if( isset($_GET['news']) and !defined('PAGE_LOADED') ) {
include 'pages/news.php';
define ('PAGE_LOADED', '');
}
if( isset($_GET['portfolio']) and !defined('PAGE_LOADED') ) {
include 'pages/portfolio.php';
define ('PAGE_LOADED', '');
}
if( isset($_GET['forum']) and !defined('PAGE_LOADED') ) {
define ('PAGE_LOADED', '');
header("Location: forum.php");
}
?>
And if you don't intend to have other query string variables:
<?php
if(isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] == 'news') {
include 'pages/news.php';
}
if(isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] == 'portfolio') {
include 'pages/portfolio.php';
}
if(isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] == 'forum') {
header("Location: forum.php");
}
?>
And thats how you do index.php?news
___________________
http://www.philbrodeur.com - Expert PHP Development and Tutorials
Last edited by Phil, June 16th, 2003 12:16 AM (Edited 1 times)

June 16th, 2003
12:09 AM
Originally posted by Ares
Updated - fixed $1337 and the register_globals inconsistence Jeb pointed out, and added the following section.
---
Now, you may ask - what about index.php?news / index.php?portfolio means of navigation? This actually isn't that hard. You see, when you go to index.php?variable, variable is initialized but not given a value. That means you can do this:
<?php
if(isset($_GET['news'])) {
include 'pages/news.php';
}
if(isset($_GET['portfolio'])) {
include 'pages/portfolio.php';
}
if(isset($_GET['forum'])) {
header("Location: forum.php");
}
?>
And thats how you do index.php?news
Use $_SERVER['QUERY_STRING'] instead. I can do this test.php?news&porfolio&forum and it'll load all three pages. The only problem with using query string is that it has to be exactly "news" or "portfolio" hence not allowing you to pass any additional variables to the next page.
___________________
http://celerondude.com

June 16th, 2003
12:16 AM
with Mr. Jones
Status: Offline!
Fixed. And CDude..the title...is missing a word? Before the :? 
___________________
http://www.philbrodeur.com - Expert PHP Development and Tutorials

June 20th, 2003
11:21 PM
Neverside Newbie
Status: Offline!
I'm using the script from here for my page.
Originally posted by CDude
for the people that didn't read the other threads
<?php
// what variable in the query string. ex; index.php?goto=some page
$var_name = "goto";
// list of your pages, what you want to call it and what file should be included.
// example 'pictures' => '/home/url/public/page/that/is/not/in/the/same/directory',
// default is the default page, duh!
// 404 is the page to load when the user wants a page that does not exist. 404.php
// can be a file that stores the URL into a text-file so you know if you have any broken links.
$pages = array(
'default' => 'main.php',
'404' => '404.php',
'pic' => 'what.php',
'page name' => 'whatever.asdfsdfdsfsdf',
);
$var = @$_GET[$var_name];
if(!$var)
include($pages['default']);
elseif(!isset($pages[$var]))
include($pages['404']);
else
include($pages[$var]);
?>
When I load the index.php page, for some reason, the default page and 404 page both show up. The default page is at the top and the 404 page is at the bottom. If I link to index.php?page=default, then it will work. Did I mess up on the coding somewhere? Here's what is looks like....
<?php
// what variable in the query string. ex; index.php?goto=some page
$var_name = "page";
// list of your pages, what you want to call it and what file should be included.
// example 'pictures' => '/home/url/public/page/that/is/not/in/the/same/directory',
// default is the default page, duh!
// 404 is the page to load when the user wants a page that does not exist. 404.php
// can be a file that stores the URL into a text-file so you know if you have any broken links.
$pages = array(
'default' => 'entry.php',
'404' => '404.php',
'contact' => 'contact.php',
'life' => 'life.php',
'location' => 'location.php',
);
$var = @$_GET[$var_name];
if(!$var)
include($pages['default']);
if(!contact)
include($pages['contact']);
if(!life)
include($pages['life']);
if(!location)
include($pages['location']);
elseif(!isset($pages[$var]))
include($pages['404']);
else
include($pages[$var]);
?>
___________________
- Eli

June 21st, 2003
12:22 AM
it shouldn't be $_GET[$var_name] it should be $_GET['var_name']
___________________


June 21st, 2003
02:14 AM
actually, either of those will work.
___________________
Current Project: LivermoreMuscle.com
Sig Hosted by Motorspin

June 27th, 2003
04:19 AM
Originally posted by Ares
maybe
<?php
switch( $HTTP_GET_VARS['what'] ) {
case 'contact' :
include 'contact/index.php';
break;
default:
include 'main.php';
break;
}
?>
Not sure if I got the path correct though - I dont know if you need contact folder
I personally need it.... its much simpler for me.
___________________
Signature Suspended as it is in violation with the signature rules

June 27th, 2003
05:37 AM
I figured it out... thanks a million Ares
___________________
Signature Suspended as it is in violation with the signature rules

June 27th, 2003
09:01 AM
<?php
function news() {
print ("This is the news page");
}
function contact() {
print ("This is the contact page");
}
switch($r) {
case 1:
news();
break;
case 2:
contact();
break;
}
?>
___________________
Graphic and Web Design services at flowtone.com