//Alias codes for the folder and the page
if (!empty($_GET['folder'])) {
$folder = $_GET['folder'];
} else {
$folder = 'flash/';
}
if (!empty($_GET['flashpage'])) {
$flashpage = $_GET['flashpage'];
} else {
$flashpage = 'news';
}
//Include on the Index.php
<?php include $folder.'/'.$flashpage.'.php'; ?>
My frist question is there I away I can use 1 link to change both setting
eg
index.php?folder=flash[b][whatgoeshere][/b]page=news1
There for it the include would goto
<?php include flash/news1.php; ?>
Second is there away I can encode the folder name..?
eg
$f = "flash/";
if (!empty($_GET['folder'])) {
$folder = $_GET['folder'];
} else {
$folder = '$f';
Get Method links.. With folder changer..
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
To have more than one variable in a query string the most common way of doing it is by joining them with an ampersand (&) so:
then the $_GET array would contain both $_GET['folder'] and $_GET['page'].
I'm not too sure what you mean by encoding the folder name though.
Mac
Code: Select all
index.php?folder=flash&page=news1I'm not too sure what you mean by encoding the folder name though.
Mac
Ive done it..
Wot I didnt want is so that would could see..
index.php?folder=3dmax&page=news1
and work out that if you goto..
folder 3dmax and page news1 eg
/3dmax/news1.php
you would get the page on its own (- the css eg)
So wot Ive done is..
added an _ to my folder names..
eg
_flash
_3dmax
_forum
_admin
And done this..
<?php $address = "_"; >
and then this on my index..
<?php include $address.$folder.'/'.$flashpage.'.php'; ?>
Do you understand?
index.php?folder=3dmax&page=news1
and work out that if you goto..
folder 3dmax and page news1 eg
/3dmax/news1.php
you would get the page on its own (- the css eg)
So wot Ive done is..
added an _ to my folder names..
eg
_flash
_3dmax
_forum
_admin
And done this..
<?php $address = "_"; >
and then this on my index..
<?php include $address.$folder.'/'.$flashpage.'.php'; ?>
Do you understand?
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You could put all your folder names into an array like so:
now $folders[1] = '3dmax', $folders[2] = 'folder2', etc...
This means that you can change your links so that instead of having
you could have
From within your code you would now do something like this:
This way you aren't showing anyone your folder names and you can also prevent them from being able to access other folders within your site that aren't specifically named in the $folders array. (in the code above && should be changed to &&)
Mac
Code: Select all
$folders = array(
1 => '3dmax',
2 => 'folder2',
3 => 'folder3',
4 => 'folder4'
);This means that you can change your links so that instead of having
Code: Select all
index.php?folder=3dmax&page=news1Code: Select all
index.php?folder=1&page=news1Code: Select all
if (!empty($_GETї'folder']) && isset($foldersї$_GETї'folder']]) {
$folder = $foldersї$_GETї'folder']];
if (!empty($_GETї'flashpage'])) {
$flashpage = $_GETї'flashpage'];
} else {
$flashpage = 'news';
}
} else {
$folder = 'flash/';
$flashpage = 'index';
}Mac