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 6 of 6

Thread: Help with GET

  1. #1
    New Coder
    Join Date
    Nov 2010
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with GET

    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..
    PHP Code:
    $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!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,511
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    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?

  • #3
    New Coder
    Join Date
    Nov 2010
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    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...

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,511
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    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".

  • #5
    New Coder
    Join Date
    Nov 2010
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    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 :/

  • #6
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,195
    Thanks
    15
    Thanked 253 Times in 253 Posts
    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 Code:

    <?php

        

        $list 
    scandir("./");



        for ( 
    $i $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/


  •  

    Posting Permissions

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