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 10 of 10

Thread: Form method

  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form method

    i know that the method attribute controls the way that the information is sent to the server, as illustrated bellow:
    <FORM ACTION = "NextPage.php" METHOD = GET>
    or:
    <FORM ACTION = "NextPage.php" METHOD = POST>
    the question is: which one should i use and why?

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, I always use POST as
    1. the data doesn't appear in the url.
    2. there are higher size restrictions on data passed (get restricts you to 256bytes)
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I agree, but there are some cases where using GET seems more appropriate:

    1. It makes the result page bookmarkable and linkable to. Look at Google for example.
    2. Because the GET variables appear in the URL, that allows users to navigate between pages using the back and forward button, without having to resubmit form values.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Ökii
    (get restricts you to 256bytes)
    It'a actually 4K in most modern browsers.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #5
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It makes the result page bookmarkable and linkable to. Look at Google for example.
    what is meaning of bookmarkable and linkable?

  • #6
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    http://www.codingforums.com/showthre...threadid=15986 is a typical URL used from a GET method, if this was done using POST, it would probably be

    http://www.codingforums.com/showthread.php

    Making it hard to bookmark or link to the correct thread

  • #7
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ???
    i didn't understand

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What exactly did you not understand?

    The difference is that with GET variables are passed per URL. That means that they appear in the URL, and if you copy-and-paste that URL e.g. into another browser window, you will still get to the correct result page.

    Compare

    http://www.example.com/result.php

    to

    http://www.example.com/result.php?id=123

    The first one could be a result page that handles form data submitted with the POST method. But the URL does not indicate that, if you type this URL (http://www.example.com/result.php) into your browser's location bar, you get to the requested document, but it might not be exactly the same because in this case no POST variables were submitted by you.

    Whereas the second URL, typed into a location bar, will *still* bring you exactly the same result page. Just try to bookmark a search result page of google, you see the difference.

  • #9
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just try to bookmark a search result page of google, you see the difference.
    what does bookmark here mean? and how can i bookmark a search result page?

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In Mozilla, when you are on the search result page, you just chose from the menu

    Bookmarks -> Bookmark this Page

    Maybe in your browser the language version is non-english and it's called something different than "bookmark", but then the PHP forums are not the right place to ask how to use the browser...


  •  

    Posting Permissions

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