...

View Full Version : Help with GET



jwilson122
11-26-2010, 01:01 AM
Okay so I'm creating my own framework script, the URL's are gonna be:
controller.php?folder=foldernamehere&page=pagenamehere

So in the controller.php I have..


$folder = $_GET['folder'];
$page = $_GET['page'];
include('plugins/'.$folder.'/'.$page.'.php');


Then in .htaccess I will do:
Rewrite On
RewriteRule ^(.*)/(.*)\.php$ controller.php?folder=$1&page=$2

Well, works out fine if I access say.. /users/index.php it will display the info perfect! But, on to my issue.
Well, say on that /users/index.php file, I want to get something from the URL... say, /users/index.php?user=bla
Well, it will not work for some reason! Any idea why? I believe its because I already have used it in the .htaccess file, but not sure.. How can I fix it? Thanks a lot!

mlseim
11-26-2010, 02:17 AM
What if they do this instead?

/users/?user=bla

Without using the assumed "index.php",
you won't have .php ... that means it will
get past the rewrite rule?

jwilson122
11-26-2010, 02:35 AM
What if they do this instead?

/users/?user=bla

Without using the assumed "index.php",
you won't have .php ... that means it will
get past the rewrite rule?

wait what? lol Sorry, I didn't exactly get what you said...

mlseim
11-26-2010, 02:41 AM
If the script you're using is called "index.php", you don't need to actually
type that in the URL, as it is the default.

/users/index.php?user=bla

is exactly the same as

/users/?user=bla

That only works for "index.php".

jwilson122
11-26-2010, 02:43 AM
If the script you're using is called "index.php", you don't need to actually
type that in the URL, as it is the default.

/users/index.php?user=bla

is exactly the same as

/users/?user=bla

That only works for "index.php".

Ohh I see now... well, any other way to do it? Because I am completely stuck, I'm not sure how to do it the correct way :/

DrDOS
11-26-2010, 04:05 AM
Here's how I did something similar for a photo gallery. You just upload a directory full of images and the PHP automatically builds a gallery, all the files used are in the main gallery directory except a message,php is copied to the albums and modified by the user.


<?php



$list = scandir("./");



for ( $i = 2 ; $i < count($list) ; $i++ )

{

$dirname = $list[$i];



if ( is_dir($dirname) )

{



if (file_exists($dirname.'/message.php'))include $dirname.'/message.php';

else copy('message.php',$dirname.'/message.php');include $dirname.'/message.php';

print '

<a href="snapshow.php?path='.$dirname.'" title="'.$dirname.'"><img src="'.$thumbnail.'"></a><br><a href="editor.php?path='.$dirname.'" title="Add a description and choose a thumbnail image.">Edit this album profile.</a><br>

';}

};



?>

First it scans the directories to see if they all have a message.php, if not one is added, then it builds a list of links to the snapshow.php and the editor.php. The links include the pathname ( directory ) and when you open either, a thumbnail page of the images is built on the fly with php.

http://drdos.x10.mx/gallery/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum