#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    How to get more data in URL


    Hello,
    I have product page that returns url like this
    127.0.0.1/page/pitem_buy.php?id=12559
    How can I, using PHP get more data in URL like product name.
    I do not need rewrite or SEO friendly URL, just need beside id, product name in any format.
    I appreciate any help, thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,233
    Rep Power
    593
    Passing parameters in the URL uses the get method in PHP. You can add any additional parameters you want by separating them with '&'. So your URL might look like:

    127.0.0.1/page/pitem_buy.php?id=12559&productname=some%20name

    Note the use of %20 to represent a space (you could also have used '+'). It is important to not use reserved characters within parameters you are trying to pass. When generating the URL in PHP you should pass that part of the URL string through 'urlencode'. If generating the URL manually then you should look at this to make sure you don't get unexpected results.

    As an aside, keep in mind that anyone can manipulate URLs to try to hack your site. Never put any sensitive data into a URL nor trust any strings in the URL (validation checking is critical to security when using the get method).

    Comments on this post

    • szkgroove agrees : Great, Thanks
    Last edited by gw1500se; November 21st, 2012 at 07:49 AM.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0
    WORKS, thanks again

IMN logo majestic logo threadwatch logo seochat tools logo