php question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

php question

Post by Illusionist »

I'm wanting to write 1 main php page, and then load seperate pages into an IFrame on that one main php page... but what i wanna do is like index.php?page=page1 and it load page1 into the IFrame, but i also want that if it is jsut index.php to load a default page intot he IFrame, how can i check if the ?page is there or not?

Sorry if this si a bit confusing... i'm a bit confused to at the moment on waht i'm really trying to do! lol

Thanks
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

to check if the ?page is there:

Code: Select all

<?php
if(isset($_GET['page']))
{
//it's set
}
else
{
//it's not set, load default page
}
?>
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

Hey, thanks thats perfect!
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Re: php question

Post by Dr Evil »

Illusionist wrote:load page1 into the IFrame
Hi this looks like a nice idea on paper, but be VERY careful you don't allow people to hack your site this way!

Check the first example here.

Dr Evil
Grumpyoldman
Forum Newbie
Posts: 1
Joined: Tue Jan 27, 2004 4:18 am

php question

Post by Grumpyoldman »

Sorry if this is just an annoying question. I am new to this and currently feeling somewhat confused.

If I use an include where links read name.php?file=name.html is it enough to add something like

$allowed_files = array
('one.html', 'two.html', 'three.html');

if( in_array($file, $allowed_files) )
{
include($file);
}
else
{
exit;
}

to the include to ensure security or am I missing something else? The idea is similar to the idea that kicked off this thread - I know that there are security issues but am unsure EXACTLY what I need to do to deal with them...
Post Reply