HTML forms - should I use GET or POST HTTP method?Which HTTP method to use for your form: GET or POST?
PHP form
 Home   Forms tutorial   How to articles   Link to us   Donations   Contact 

PHP form > How to > Which method to use for your form: GET or POST?

Should I send form data using GET or POST method?

When using HTML forms you can set the form method parameter to either "GET" (default) or "POST". So, which one to use?

When working with GET method you can access all form variables with the $_GET array in PHP and when using POST you can access the variables using $_POST as shown in our PHP forms tutorial. No matter which method used you can also access all variables using $_REQUEST array.

When using GET all the submitted information is displayed in the address bar as part of the URL. You will see that as information shown after ? (called a query string), something like:

http://domain.com/script.php?name1=value1&name2=value2

This can be useful for example where you want to be able to bookmark a page with specific query string values. However, the GET method is limited by the length of the URL (2083 characters in Internet Explorer according to Microsoft) and each of the input values must not exceed 100 chars. Obviously you also don't want to use GET when submitting sensitive information like passwords or credit card details as they would show up in the address bar.

The POST method can send a lot of data (usually limited by the server settings) and should be used for every form unless the specific application benefits from the query string in the URL when using GET. No submitted data is shown in the address bar so most browser cannot correctly bookmark pages shown after a HTTP POST method.

There you have it. Unless you need the query string that you get when using the GET method (and aren't effected by it's limits) you should use POST for your forms. If you are submitting any sensitive information that should not be displayed in the address bar the only way to go is with the POST method.

 


Jump to:  
  2.1 PHP form not working
  2.2 Sending form results to multiple recipients
  2.3 Sending an autoresponder message
  2.4 Make sure form e-mails are not blocked by your SPAM filter
  2.5 Stop form SPAM without using Captcha
  2.6 Which method to use for your form: GET or POST?
  2.7 Contact forms or Help desk software?
  2.8 Prevent multiple form submissions
  2.9 Secure order forms
  2.10 Hosting and PHP forms

Help desk software Hesk

» Copyright notice

© 2008-2024 myPHPform.com. All rights reserved. Copying or redistributing any part of this website without our written permission is expressly forbidden!

Page copy protected against web site content infringement by Copyscape

 


Help desk software

Help myPHPform by Donating!

  Home  Forms tutorial  How to articles  Link to us  Donations  Contact  
 
© Copyright PHP form 2008-2024. All rights reserved.
All trademarks are property of their respective owners.
Privacy policy