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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    824
    Thanks
    93
    Thanked 18 Times in 18 Posts

    POST vs GET for inserting into a database

    I want to use an AJAX form to insert data into a database, personally id rather use POST rather than GET but i was wondering if any were specifically better either speed wise or safety wise etc. Any input appreciated.

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,373
    Thanks
    11
    Thanked 592 Times in 572 Posts
    GET is a lot faster, but often considered less safe than POST.
    The reson is that GET is part of the URL, so it shows up in logs from your windows box to the coffershop's router to your ISP's logs, to the site's logs...

    POST is not logged as such, and handles more data than GET.

    Still, GET is easier to debug because the url (and all those logs) contain the actual data you passed.

    You can send GET from any domain to any domain without security warnings, whist POST usually requires a real <form> and security click-through to do xdomain transfers.

    if you use ajax, neither can talk to other domains.
    using an image ping, you can GET to anywhere, but not from anywhere...


    so, it depends on:
    1. how much data you have (+2kb needs post)
    2. where it's going? (same site or elsewhere)
    3. security implications (don't login to a bank at starbucks using GET to submit)
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%

  • Users who have thanked rnd me for this post:

    tomharto (06-01-2011)


  •  

    Posting Permissions

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