PHP for the World Wide Web (Visual QuickStart Guide)
I l @ ve RuBoard |
The experienced reader will notice that we are missing one thing in our initial <FORM> tag, namely adding a METHOD attribute. This attribute tells the server how to transmit the data from the form to the handling script. I omitted it earlier because the topic merits its own discussion. There are two choices you have with METHOD: GET or POST. I suspect that most HTML coders are not entirely clear on the distinction and when to use which. In truth, for the most part it won't make much difference ( especially as you first begin using them) as either will generally get you the results you need. The difference between using GET versus POST is squarely in how the information is passed from the form to the processing script. The GET method will send all the gathered information along as part of the URL. The POST method transmits the information invisibly to the user . For example, upon submitting your form, if you use the GET method, the resulting URL will be something like: http://www.DMCinsights.com/php/ HandleForm.php?FirstName= Larry&LastName=Ullman. Whereas using the POST method, the end user would only see http://www.DMCinsights.com/php/ HandleForm.php. When choosing which method to use, you may want to keep in mind these three factors: 1) with the GET method you are limited as to how much information can be passed; 2) the GET method publicly sends the input to the handling script (which means that, for example, a password which is entered in a form becomes viewable by anyone within eyesight of the Web browser, creating a larger security risk); and, 3) a page generated by a form that used the GET method can be bookmarked while one based upon POST cannot be. In this text, I will use POST for handling forms, mostly to distinguish from a technique I will use where the GET method theory adds capabilities to your Web site (see Inputting Data Manually ). Either method will successfully pass along the data from the form and the final decision for which method you use should be based upon any mitigating factors in your form and whether or not the resulting page should be bookmark-able. To add a method to your script:
Script 3.3. It is up to you whether to use the GET or POST method as long as you remember to use one of them. With experience you will determine when it makes sense to use one rather than the other, but it is more of a finesse than function issue.
|
I l @ ve RuBoard |