Trouble using PHP Switches

Hi, I’m trying to build a small site for my development section of my site but I need some help.

This is the current code:

<?php
// This document contains the possible switches for this site.
// Site switches.
if (isset($_GET['page'])) $PAGE = $_GET['page'];
else $PAGE = 'index';
switch ($PAGE) {

//1- index
case 'index':
	include ("static/index.shtml");
	break;

case 'page1':
	echo "Test";
	break;

//Error Document
default:
	include ("static/error.shtml");
	break;
}

// Development Sites.
if (!isset($_DEVELOPMENT['site'])) $DEV = $_DEVELOPMENT['site'];
switch ($DEV) {

//2- phpbb2
case 'phpbb':
	header ("Location: forums/phpbb/");
	break;

//3- smf
case 'smf':
	header ("Location: forums/smf/");
	break;

//4- xmb
case 'xmb':
	header ("Location: forums/xmb/");
	break;
}
?>

I want to be able to use ?site=site to redirect the user to the site and use ?page=page for internal pages. I want all the php in one document and the internal pages in html files placed in another folder.

I know it can be done, I just don’t know how. Please help…

what is $_DEVELOPMENT[‘site’] ought to be?
has to be $_GET[‘site’]

the rest look ok.

r u getting any errors?

what is working and what is not?

$_DEVELOPMENT[‘site’] is for the second set of switches. The only problem is I can use any of the site switches. The pages work, but not site.

EDIT: I changed DEVELOPMENT to GET and now I encounter a conflict.

ERROR:

[code]This is the index page of Michael’s Web Development.

Warning: Cannot modify header information - headers already sent by (output started at /var/www/dev.michaels-web.org/public_html/static/index.shtml:8) in /var/www/dev.michaels-web.org/public_html/index.php on line 29
[/code]

make sure there is no whitespace (linfeed, blank) before the ‘<?php’.

There’s no white space in the document a far as I know of. I’ve used the same application on many php and html documents. I still have problems with it.

thing i got it: include (“static/index.shtml”); is creating the output.

use the switch($DEV) before switch($PAGE) should solve it.

Excellent! Now how can I add a error document for the sites switch? I’m thinking of using a header redirect for that but I think it will cause another problem.

use the same ‘default:’ for the site-switch as u use for the pages-swich

I did that but now it shows the error page above the welcome page.

have u solverd this already?

u would need an if/else to just prosses the data submitted.dosn’t matter which way around cause there should be never $_GET[‘page’] and $_GET[‘site’] the same time.

so just do:

if(isset($_GET['page'])) { first switch. } else if(isset($_GET['site'])) { second switch } else { error/default }

It’s not working like it should.

This is the current code:

<?php
// This document contains the possible switches for this site.
// Development Sites.
if (isset($_GET['site'])) $DEV = $_GET['site'];
switch ($DEV) {

//2- phpbb2
case 'phpbb':
	header ("Location: forums/phpbb/");
	break;

//3- smf
case 'smf':
	header ("Location: forums/smf/");
	break;

//4- xmb
case 'xmb':
	header ("Location: forums/xmb/");
	break;
}

// Site switches.
if (isset($_GET['page'])) $PAGE = $_GET['page'];
else $PAGE = 'index';
switch ($PAGE) {

//1- index
case 'index':
	include ("static/index.shtml");
	break;

case 'page1':
	echo "Test";
	break;

//Error Document
default:
	include ("static/error.shtml");
	break;
}
?>

I need an error page for the sites switch but when I add one, it includes the development sites switch error page on top of the sites switch.

Sponsor our Newsletter | Privacy Policy | Terms of Service