...

View Full Version : $_GET alternative?



PaulC2K
01-24-2012, 12:59 AM
Not sure how else to put it tbh, my coding practices have put me in a bit of a dilemma, and as a result i've now realised that part of it no longer functions and its because im 'botching' part of the site and any posted (think thats the right term) variables are being completely ignored, albeit intentionally i guess.

My coding terminology is a bit limited, which doesnt help when trying to look for solutions or asking for help, so i'll try and explain the situation as best as possible...

In certain sections of my site im using a .htaccess to read a url that doesnt exist, acts like it does and shows the information you'd expect it to show.

example url: mydomain.com/username/paulc2k/index.php?foo=bar
or any username could be entered, and as long as its in the database it'll show information based on that. Its fairly important to have it like this though, it allows me to have meaningful URLs.

my .htaccess file would pass the 'paulc2k/index.php' part, and even an additional subfolder if provided, and run it through a page to decide what it all means and show the relevant information for the visitor.
The problem is , thats stealing my 'GET/POST' data, theres effectively nothing being posted to get, so if it isnt hardcoded or a part of the file structure of the URL, theres no way of getting or using GET/POST.

I need to use what looks like a 3 tier folder structure, without having to have every single folder, and the relevant files within them. I also need to be able to display links with dynamic urls to show those results, and all at the same time. It doesnt need to be pretty (simple is good though!) as long as it reads that example url and $foo = bar when i need to ask.

Hopefully enough of the above makes sense to someone out there and theres a solution which lets me continue. I get the feeling im going to be up a famous creek without a paddle :(

BluePanther
01-24-2012, 01:05 AM
Not sure how else to put it tbh, my coding practices have put me in a bit of a dilemma, and as a result i've now realised that part of it no longer functions and its because im 'botching' part of the site and any posted (think thats the right term) variables are being completely ignored, albeit intentionally i guess.

My coding terminology is a bit limited, which doesnt help when trying to look for solutions or asking for help, so i'll try and explain the situation as best as possible...

In certain sections of my site im using a .htaccess to read a url that doesnt exist, acts like it does and shows the information you'd expect it to show.

example url: mydomain.com/username/paulc2k/index.php?foo=bar
or any username could be entered, and as long as its in the database it'll show information based on that. Its fairly important to have it like this though, it allows me to have meaningful URLs.

my .htaccess file would pass the 'paulc2k/index.php' part, and even an additional subfolder if provided, and run it through a page to decide what it all means and show the relevant information for the visitor.
The problem is , thats stealing my 'GET/POST' data, theres effectively nothing being posted to get, so if it isnt hardcoded or a part of the file structure of the URL, theres no way of getting or using GET/POST.

I need to use what looks like a 3 tier folder structure, without having to have every single folder, and the relevant files within them. I also need to be able to display links with dynamic urls to show those results, and all at the same time. It doesnt need to be pretty (simple is good though!) as long as it reads that example url and $foo = bar when i need to ask.

Hopefully enough of the above makes sense to someone out there and theres a solution which lets me continue. I get the feeling im going to be up a famous creek without a paddle :(

Hard to understand really. Are you using your .htaccess to rewrite the url to get rid of the query string? This shouldn't stop POST information from being passed, as POST isn't in the query string - it's sent along with the content headers.

PaulC2K
01-24-2012, 01:15 AM
php_flag register_globals on

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*).*$ analyse.php?value=$1
Thats what im using for the .htaccess

Truth be told, i stared working on this project almost 2yr ago, and stopped about 16mo ago and so a lot of what ive done is a bit of a mystery, my brain is a sieve when it comes to coding :(
I know analyse.php is where im reading the info and deciding what to do with it. From that, im using explode to pull 3 values, folder, subfolder, & filename.
I dont recall much from constructing the htaccess file, it consists of snippets found via google and a lot of trial and error. I dont fully know what a lot of that is getting at, so maybe im not telling it to even expect anything as a posted value?


hmm, ive found a similar example (from here, dated 2005!) where they've used {QUERY_STRING}, is it perhaps possible to use both? is that where im going wrong?

PaulC2K
01-24-2012, 09:59 AM
Seems this issue isnt php related so i'll start a thread in the apache area, hopefully it'll make sense in there :)

edit - ended up stumbling upon the answer, needed to use [QSA] on the RewriteRule to get it to recognise the additional info. coincidentally i found the info from the post i'd mentioned above last night, i just didnt know what it meant.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum