06-01-2016, 03:03 PM
The text box is convenient for this example because you can see it, but using a text box this way in real programs causes serious problems. Text boxes are editable by the user, which means she could insert any kind of information and really mess up your day.
Hidden form fields are the unsung heroes of server-side programming. Look at $hdnCounter in the source code. This hidden field also has a counter, but the user never sees it. However, the value of the $hdnCounter variable is sent to the PHP program indicated by the form’s action attribute. That program can do anything with the attribute, including printing it in the HTML code body.
A simple way to track information between pages is to store the information in hidden fields on the user’s page.
The hidden fields technique shown here works fine for storing small amounts of information, but it is very inefficient and insecure when you are working with more serious forms of data.
Hidden form fields are the unsung heroes of server-side programming. Look at $hdnCounter in the source code. This hidden field also has a counter, but the user never sees it. However, the value of the $hdnCounter variable is sent to the PHP program indicated by the form’s action attribute. That program can do anything with the attribute, including printing it in the HTML code body.
A simple way to track information between pages is to store the information in hidden fields on the user’s page.
The hidden fields technique shown here works fine for storing small amounts of information, but it is very inefficient and insecure when you are working with more serious forms of data.