Jump to content

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


fallenone1884

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]
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.