[PHP]Security

Results 1 to 12 of 12
  1. #1
    Sorcerer Supreme Hidden is offline
    Member +Rank
    Apr 2008 Join Date
    .Location
    367Posts

    [PHP]Security

    So i was wondering what type of method i should use so that no one could make a form on their website that could access my scripts,
    right now i use $_REQUEST for everything, and $_GET if its something like
    index.php?action=1
    so i was wondering what i should use for forms and what i should use for anything else?
    Thanks


  2. #2
    Fuck you, I'm a dragon Pieman is offline
    Grand MasterRank
    Apr 2005 Join Date
    The NetherlandsLocation
    7,412Posts

    Re: [PHP]Security

    Always use post whenever possible.

  3. #3
    Elite Member andrew951 is offline
    Member +Rank
    Dec 2006 Join Date
    207Posts

    Re: [PHP]Security

    yeah. with get, people can hack it and stuff, but with post it is sent like sessions.

  4. #4
    Sorcerer Supreme Hidden is offline
    Member +Rank
    Apr 2008 Join Date
    .Location
    367Posts

    Re: [PHP]Security

    Makes perfect sense, but when should i ever use get? or request? or should i always use post?

  5. #5
    Fuck you, I'm a dragon Pieman is offline
    Grand MasterRank
    Apr 2005 Join Date
    The NetherlandsLocation
    7,412Posts

    Re: [PHP]Security

    I only use get for search functions.

  6. #6
    Elite Member andrew951 is offline
    Member +Rank
    Dec 2006 Join Date
    207Posts

    Re: [PHP]Security

    I use get for password recovery activations. or to just use index.php.
    simple stuff like that. otherwise, i would use post or sessions. even if php is server-sided, it can still get hacked.
    so we as coders must try to stop it. haha.

  7. #7
    Grand Master King Izu is offline
    Grand MasterRank
    Dec 2006 Join Date
    833Posts

    Re: [PHP]Security

    Post data can be just as easily changed as data in a query string. It's in no way more 'secure' than putting data in a query string. $_REQUEST contains the same data as $_GET and $_POST, so it doesn't matter if you use $_REQUEST instead of $_GET and vice versa.

    If I'm not writing a small application (like less than 4 source files), I don't bother with $_GET (or $_REQUEST) at all.

    As for ensuring that only forms from your site are used to access your script. Check out the HTTP_REFERER although it's REALLY not that reliable. It's all up to the user's client. You really shouldn't worry about other sites having forms directed at your scripts, since there's not much vulnerability there.

  8. #8
    Member fook3d is offline
    MemberRank
    Sep 2007 Join Date
    Leicester, UKLocation
    65Posts

    Re: [PHP]Security

    Quote Originally Posted by andrew951 View Post
    yeah. with get, people can hack it and stuff, but with post it is sent like sessions.

    Hack? No!

    Well, thats not entirely true, you can only exploit an application if you fail to secure users input, which you should always assume to be unsafe.

    If you don't secure it, your the one letting it be abused.

    I always use the following to check data before inserting into the database or allowing the data to be output to the browser

    eregi();
    htmlspecialchars();
    mysql_real_escape_string();
    stripslashes();
    strip_tags();

    And a few others I can't think of right now.

  9. #9
    Grand Master Daevius is offline
    Grand MasterRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [PHP]Security

    Instead of eregi, it's faster to use preg_match ;)

  10. #10
    Sorcerer Supreme admLoki is offline
    Member +Rank
    Apr 2005 Join Date
    www.codenetwork.ruLocation
    345Posts

    Re: [PHP]Security

    Use regular expressions.
    E.g. :
    PHP Code:
    $id preg_replace("/[^0-9]/","",$_GET['id']); 

  11. #11
    Grand Master john_d is offline
    Grand MasterRank
    Feb 2004 Join Date
    PhilippinesLocation
    2,868Posts

    Re: [PHP]Security

    doesn't matter what u use.

    $_GET give u a lot of stuff POST will never give. $_GET make navigation better since when u refresh it.. it will not give u that annoying popup.. requiring to send data again.

  12. #12
    Grand Master Daevius is offline
    Grand MasterRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [PHP]Security

    Quote Originally Posted by john_d View Post
    it will not give u that annoying popup.. requiring to send data again.
    Urm, disable the window? It never appeared for me...ever.

    FYI, GET and POST are the same, except in the way they are sent. GET goes via the request URL while POST has some more transparent way of reaching the server. There's no better or worse.



Advertisement