Wednesday, July 15, 2009

What is the difference between "POST" & GET Methods? I want to know about the HTML For

I am coding a form for a website. But the problem is that how can I store feedback from the users on the website storage.



A feedback form that stores data on the space in the hosted domain.



What is the difference between %26quot;POST%26quot; %26amp; GET Methods? I want to know about the HTML Forms for feedback.





Hi,



Many people asked me this question numerous times. It is a confusing matter I guess :)



But let me tell you this:



When you have a form, you need to submit the data you have entered the form, correct?



Ok now, we have 2 different ways of submissions.



POST - sends it in the body of the submission.



GET - send the form input in an URL



Ok, now you would tell me what that means.



Think of POST as HIDDEN. It would be hidden data embedded within the form.



Think of GET as your variables are attached to your URL.



Here is an example:



The form is located here: http://www.myweb.com/form.php



%26lt;form action=%26quot;%26quot; method=%26quot;get%26quot;%26gt;



%26lt;input type=%26quot;text%26quot; name=%26quot;FullName%26quot; value=%26quot;%26quot; /%26gt;



%26lt;input type=%26quot;text%26quot; name=%26quot;FeedBack%26quot; value=%26quot;%26quot; /%26gt;



%26lt;input type=%26quot;submit%26quot; name=%26quot;Submit%26quot; value=%26quot;Enter%26quot; /%26gt;



%26lt;/form%26gt;



That would be a form that has 2 fields, FullName and FeedBack. Once you press on the Enter button, The URL will look like this:



http://www.myweb.com/form.php?FullName=B...



Notice the 2 fields (FullName and FeedBack) which are variables on how they are transformed...



Later when programming you need to catch the URL Variables usually there are function, in PHP it is $_GET[%26#039;FullName%26#039;], That is how you grab the contents of the variables in a GET within php. In JSP and ASP it is doGet() something like that.



-------------------------------



Okay so for GET it is attached to the URL, now for POST.. It is hidden...



Here is an example:



The form is located here: http://www.myweb.com/form.php



%26lt;form action=%26quot;%26quot; method=%26quot;post%26quot;%26gt;



%26lt;input type=%26quot;text%26quot; name=%26quot;FullName%26quot; value=%26quot;%26quot; /%26gt;



%26lt;input type=%26quot;text%26quot; name=%26quot;FeedBack%26quot; value=%26quot;%26quot; /%26gt;



%26lt;input type=%26quot;submit%26quot; name=%26quot;Submit%26quot; value=%26quot;Enter%26quot; /%26gt;



%26lt;/form%26gt;



When I press the submit button the URL will look like this:



http://www.myweb.com/form.php



Notice, same thing... The variables are intact within hte form in memory. in programming language you access it with $_POST[%26#039;FullName%26#039;];



Okay your wondering what the difference from POST is to GET, GET can be used in Forms, links , anything that is a link.. POST is only for forms... POST is used to store secure data, so the user cannot change the contents while sending it in the programming script.



IT is more securer...



Read online to know more about the differnces :)



I hope I helped



What is the difference between %26quot;POST%26quot; %26amp; GET Methods? I want to know about the HTML Forms for feedback.



The HTML specifications technically define the difference between %26quot;GET%26quot; and %26quot;POST%26quot; so that former means that form data is to be encoded (by a browser) into a URL while the latter means that the form data is to appear within a message body. But the specifications also give the usage recommendation that the %26quot;GET%26quot; method should be used when the form processing is %26quot;idempotent%26quot;, and in those cases only. As a simplification, we might say that %26quot;GET%26quot; is basically for just getting (retrieving) data whereas %26quot;POST%26quot; may involve anything, like storing or updating data, or ordering a product, or sending E-mail.

No comments:

Post a Comment