views:

27

answers:

2

What are the data type limitations of the POST and GET HTML Form Methods? Are you limited to passing only specific data types like--strings, integers, floats.

+1  A: 

POST and GET both submit strings to the server. It is up to your program to determine how to parse that data. Most frameworks give you a basis to do this already that support most primitive datatypes. In the case of ASP.NET MVC, it can bind to most objects.

Keith Rousseau
So I would have to do a work around if I wanted to submit a class or an array?
Brook Julias
That completely depends on what framework you are using. In ASP.NET MVC, the ModelBinder will take care of binding your data to a class. It is based on naming conventions. http://msdn.microsoft.com/en-us/library/dd410405.aspx
Keith Rousseau
I am using PHP with no other framework when what is involved with the initial install.
Brook Julias
Well in that case you will have to go into the $_POST array and get the variables out on your own and convert them to your datatype. There are a number of MVC frameworks for PHP - I would suggest that you use one - http://stackoverflow.com/questions/1961669/php-mvc-framework
Keith Rousseau
A: 

Of what I'm aware, there's no data type limitations, but there's another limitation. GET has a maximum length that varies between browsers. As a general rule, I use POST for form submissions that doesn't require that the user should be able to bookmark or send the URL to someone.

Gert G