Jump to content


Photo

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


  • Please log in to reply
3 replies to this topic

#1 fallenone1884

fallenone1884
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 12 September 2006 - 11:05 PM


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


<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;


#2 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 12 September 2006 - 11:13 PM

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:
else
{
   $file = '../MyDirectory/Welcome.php';
}

Ronald  8)

RTFM is an almost extinct art form, it should be subsidized.

#3 fallenone1884

fallenone1884
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 12 September 2006 - 11:20 PM

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 file_exists('./pages/' . $p . '.php') and $file = './pages/' . $p . '.php'; 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.

#4 fallenone1884

fallenone1884
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 13 September 2006 - 12:06 AM

Ok got it, just use an

elseif

:)

works great




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users