Click to See Complete Forum and Search --> : New query to bug you!!!


Teach
12-11-2003, 04:07 PM
Hello.
Sorry to bother you again !!!
Not sure if I was meant to start a new thread about this, sorry -- but seeming as it's a new question I felt it appropriate.
Basically, just wondering if this is possible (and how!), i want to have a page that will load others, by this i mean I want a "sales.php" which can then have say, "sales.php?id=toys" and it would load "toys.html" in the header/footer. The toys.html and other .html files that I want would be in the "sales" directory. How can I do this? I saw something like it with skydan's post - but there was never a fix for this, but I see a secure way at the end that wasn't fixed.
That he had just the specific id's and filenames that could be loaded, and that one specific directory that could only be loaded from. Tehre would literally only be about 6 id's and .html files - so i could list them, to secure this "sales.php".
How do you suggest I do this?

Many thanks in advance.

olaf
12-11-2003, 04:35 PM
switch ($id) {
case "toys':
$header = "toys.htm";
break;
case "sales":
$header = "sales.htm";
break;
}

use the $heade variable in yout frame set.

Teach
12-11-2003, 04:54 PM
Hi there, and thanks.
Can I not use something like this: http://forums.web-developer.com/showthread.php?threadid=22479&pagenumber=3

the first post there.
Thanks.

olaf
12-12-2003, 01:59 AM
why???

you want to use different files in different cases...

Zibings
12-12-2003, 05:48 AM
I think Olaf did provide you with a good solution here. Considering everything you've asked for, adding another variable to your query line (and of course to Olaf's switch statement) will help you get the result you want.

page.php?id=sales&dir=sales <-- new variables $dir


At the top of your page:

if ( isset($id) || !empty($id) )
{
switch ( $id )
{
case ....
default:
$page = "page.html"; //<-- "security" in case someone tries to play around with the script
}
}

if ( isset($dir) || !empty($dir) )
{
switch ( $dir )
{
case ...
default:
$dir = "sales";
}
}

$location = "./".$dir."/".$page.".html";


Same thing, a little "dirty" so to speak, but it would give you what you wanted, just like Olaf said.

Teach
12-12-2003, 03:00 PM
Hi there and thanks. That indeed is what i'm looking for except the "dir" thing, although that seems a little insecure to say what "skydan" was trying to do on that post I put on the first post of this thread.
How can i use that to achieve that with itgiving the actual only directory it can load from and specific files?

Thank you.

Zibings
12-12-2003, 07:31 PM
Change this:


$location = "./".$dir."/".$page.".html";


to:


$location = "./dirname/".$page.".html";


and take out all the code that dealt with the $dir variable.