Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Posts
    131
    Thanks
    21
    Thanked 0 Times in 0 Posts

    $_GET alternative?

    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

  • #2
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Quote Originally Posted by PaulC2K View Post
    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.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • Users who have thanked BluePanther for this post:

    PaulC2K (01-24-2012)

  • #3
    Regular Coder
    Join Date
    Jul 2005
    Posts
    131
    Thanks
    21
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by .htaccess
    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?
    Last edited by PaulC2K; 01-24-2012 at 12:20 AM.

  • #4
    Regular Coder
    Join Date
    Jul 2005
    Posts
    131
    Thanks
    21
    Thanked 0 Times in 0 Posts
    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.
    Last edited by PaulC2K; 01-24-2012 at 12:16 PM. Reason: update


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •