Jump to content

Archived

This topic is now archived and is closed to further replies.

fallenone1884

$p = $_GET['p']; Help Please ! :P

Recommended Posts


Ok i have this code, im not sure entirley how it works, but know it works for what i am doing, including different pages inside my main.php page. My question is there anyway to make it pull from two directory's instead of just /pages/ i think its making it so only one directory is available for the function for security. So in keeping with security but opening the call for more then one directory, is it possible? and how do i go about doing it. I can clarify if asked, i stumble accross my own thoughts alot..

Thanks
oh heres the code


[code]<p align="center">
  <?php
$p = $_GET['p'];
if ( !empty($p) && file_exists('./pages/' . $p . '.php') && stristr( $p, '.' ) == False )
{
   $file = './pages/' . $p . '.php';
}
else
{
   $file = './pages/welcome.php';
}

include $file;[/code]

Share this post


Link to post
Share on other sites
Hope I understand correctly. Assume that you want your welcome page to come from another directory, say MyDirectory, which is one level up in the tree, just specify in your ELSE clause:
[code]
else
{
  $file = '../MyDirectory/Welcome.php';
}
[/code]

Ronald  8)

Share this post


Link to post
Share on other sites
Sorry for being unclear, Im looking to do something like this

main.php?p=apage

the directory of this page named /pages/

that works with this code

seeing, that [color=brown]file_exists('./pages/' . $p . '.php') and $file = './pages/' . $p . '.php';[/color] are calling for the pages directory.

what i want to do is do the same thing

main.php?p=anotherpage

the directory of anotherpage named /anotherdir/

when i try to do this, nothing comes up, because im assuming, anotherpage is not in the pages directory.

I dont know, i just started all this last night, so trying to figure it out, sorry if im not relaying the information right.

My question is there a way to add the second directory so that when i do

main.pgp?p= it looks in both the pages directories and the anotherdir directory, not just pages.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.