Passing parameters in the URL

Discussion in 'PHP' started by UCDaZ, Nov 2, 2008.

  1. #1
    In my url i'm passing parameters like
    www.myexample.com?BusinessId=5
    The 5 in this case is the primary key of the database table "business."
    Should I hash the "5" or is it ok to tell the world the primary key id?
    Are there any security issues I should worry about?
    Thanks!
     
    UCDaZ, Nov 2, 2008 IP
  2. skateme

    skateme Peon

    Messages:
    162
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Of course you should worry! Instead of using GET, use POST! SQL injection can get very easy if the injector finds out the businessid is the key of your database..
     
    skateme, Nov 2, 2008 IP
  3. penalty

    penalty Member

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    hi
    it is very important to check the respective variable of its type because you don't want anybody to pass a char if you need an integer
     
    penalty, Nov 2, 2008 IP
  4. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #4
    ^Why do you POST is safe in that aspect? Can't an ill-intentioned use just see the HTML source and read the field names that you are passing?

    Anywayz, whether you are using GET or POST, you MUST always use the mysql_real_escape_string() functions.
    
    $business_id=mysql_real_escape_string($_GET['business_id']);//much safer
    $business_id=$_GET['business_id'];//may give up to a basic SQL injection attack.
    //Just using POST does not make it more secure!
    
    PHP:
    Another way to hide the id is using URL rewriting with .htaccess capabilities, but that may be difficult for you at this moment.
     
    rohan_shenoy, Nov 2, 2008 IP
  5. UCDaZ

    UCDaZ Active Member

    Messages:
    180
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    So it's ok as long as I sanitize my incoming data by escaping all of the weird characters?
     
    UCDaZ, Nov 3, 2008 IP
  6. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #6
    Yeps. Nothing to do with Post or Get.
     
    ads2help, Nov 3, 2008 IP
  7. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #7
    Yes, if you sanitize incoming data, its all OK. But I think there is a limit upto 100 characters that can be passed via GET. POST has no such limititations.
     
    rohan_shenoy, Nov 3, 2008 IP
  8. techcone

    techcone Banned

    Messages:
    206
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #8
    SQL injection has nothing to do with GET or POST, using a simple addon called Tamper Data, you can change GET to POST :).
     
    techcone, Nov 3, 2008 IP