Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 10 of 10
  1. #1
    Junior Member Lucian's Avatar
    Join Date
    Aug 2003
    Location
    tennessee
    Posts
    18
    Member #
    2765
    Hi everyone,

    I'm trying to develop a script that will allow me to use straight numbers from the url requesting a document. Currently, I have the script set up to where the url request looks like this:

    http://www.mysite.com/?a=123

    I want it to look like this:
    http://www.mysite.com/?123

    I'm just not sure how to fetch that value for use in the script, and I've seen other sites do it.

    I.E. if you go to yessoftware.com and signup as an affiliate their affiliate url's look the way I want mine to look, and they use php.

    Any Ideas, code chunks or suggestions how I can solve this problem?

    Thanks,

    Lucian
    Are your website promotion efforts yielding less than satisfactory results? Check out the Website Promotion Tips Blog for help!

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    ?123 isn't a valid querystring parameter, but you can get it by retrieving the entire querystring and parsing it manually (not recommended).

    EDIT: the reason I don't recommend it is that if in the future you want to add parameters, you can't easily do so... you will have to then create a way of delimiting your values (such as with pipes), so your querystring will look like ?123|456|789 which essentially does the same thing as ?a=123&b=456&c=789 only flattening it so that you have to know what order the values are coming in, and you'll also have to create a custom querystring parser.

    Bottom line... why reinvent the wheel? Just use the standards already developed.

  4. #3
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    PHP Code:
    foreach ($_GET as $key => $value)
    {
        if (
    $key == "123")
        {
            echo 
    "?123 or &123 was in the query string\n";
        }

    But Transio's point is more important: use the standards.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  5. #4
    Junior Member Lucian's Avatar
    Join Date
    Aug 2003
    Location
    tennessee
    Posts
    18
    Member #
    2765
    Thanks guys,

    if it weren't for you I probably would have shot myself in the foot, as when I roll this product out I want to make it as easy as possible to upgrade and improve the code to support future demands.

    You guys are lifesavers,
    Lucian
    Are your website promotion efforts yielding less than satisfactory results? Check out the Website Promotion Tips Blog for help!

  6. #5
    Member Seraph's Avatar
    Join Date
    Sep 2003
    Posts
    81
    Member #
    3090
    no wait wait wait wait. Come on guys you don't know how to do this? aw man....

    There is a Server variable that get the whole get string AFTER phpfile name.

    index.php/modules/test
    you don't even need the ? it will fetch the /modules/test

    $_SERVER["PATH_INFO"]

    That variable will retrieve it. that is what I use. I then redefine $_GET

    list($_GET["mod"],$_GET["act"],$_GET["code"]) = explode("/",$_SERVER["PATH_INFO"]);

  7. #6
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Originally posted by transio
    ?123 isn't a valid querystring parameter, but you can get it by retrieving the entire querystring and parsing it manually (not recommended).
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  8. #7
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Seraph,

    Of course i know how to do it. The reason I didn't post details on how to do it is that it's a bad practice to get into, and Lucian is better off learning good programming practices such as using QueryStrings properly. I think you could learn a lesson from this post yourself.

    The lesson:

    Don't waste your time reinventing protocols and procedures that are well established, commonly accepted, and perfectly functional the way they are... ESPECIALLY when your reinvention eliminates existing functionality rather than adding functionality.

    Had your QueryString replacement added some multi-dimensional or self-identifying capacity to it that's not supported by the current QueryString format, I might have been more impressed, but as it is, it's useless, and I wouldn't suggest that anyone use it.

  9. #8
    Member Seraph's Avatar
    Join Date
    Sep 2003
    Posts
    81
    Member #
    3090
    lol true true but it is handy for redirection and file-gates
    I do think tho that it does look much cleaner than the standard query string

  10. #9
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Originally posted by Seraph
    lol true true but it is handy for redirection and file-gates
    So are normal querystring parameters.
    I do think tho that it does look much cleaner than the standard query string
    Looks worse to me... primarily because your delimiting character is a forward-slash (/), which is already a reserved url character. On servers that allow dots (.) in folder names, your querystring would be confused for a folder specification. Furthermore, your querystring doesn't allow naming of parameters and prevents sending slashes (/) as a part of a value.

    In short, it may look "neat", but your custom querystring implementation is just plain bad.

    Stick with the original.

  11. #10
    Member Seraph's Avatar
    Join Date
    Sep 2003
    Posts
    81
    Member #
    3090
    True true


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:31 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com