What is the purpose of it? It always appear at the end of forms. I have searched the web for answers but none seems to explain it clearly. Can someone please enlighten me?
@TJ111Sep 18.2007 — #It's usually a way people use to store variables that they don't want the user to see, but that they want included with the form information. An example would be on my "Contact Us" form I use PHP to set the value's of hidden inputs to the user's IP address.
@ZnupiSep 18.2007 — #It's usually a way people use to store variables that they don't want the user to see, but that they want included with the form information. An example would be on my "Contact Us" form I use PHP to set the value's of hidden inputs to the user's IP address.[/QUOTE] You are right but I don't understand why you would store a user's IP address in a hidden field... I mean, you can always read it from $_SERVER['REMOTE_ADDR'], even if you are handling some form info...
@TJ111Sep 18.2007 — #It just made it easier for processing the form information in my mail script (I'm lazy). I use extract($_POST) to get all the variables for my form information. I guess a better example would be on some forms I use it to store values pulled from a database with ajax relative to whatever a user is doing.
@CentauriSep 18.2007 — #Some mail programs like Formmail require fields sent to them with the form data to indicate things like address to send to, the confirmation page url, subject text etc. The hidden field ensures that this is not visible to the user, but still gets sent with the data.
@ray326Sep 18.2007 — #And "hidden from the user" doesn't mean it's secret or secure, just that it isn't visible on the page. It is readily available to anyone who looks at the page source.
@firblazerauthorSep 19.2007 — #It's usually a way people use to store variables that they don't want the user to see, but that they want included with the form information. An example would be on my "Contact Us" form I use PHP to set the value's of hidden inputs to the user's IP address.[/QUOTE]
@felgallSep 19.2007 — #Well they are actually constants rather than variables as far as the HTML is concerned - they only become variables in the script that the form content is passed to.
will pass two constant values to the form processor along with the values entered into the form fields. If the form is posted to PHP then these two fields would be accessible in PHP as $_POST['variableOne'] and $_POST['variableTwo'] and would have values of 'firstValue' and 2 respectively. If a different server side scripting language is used then the same two fields would be passed, just the exact wat that the two fields are named would be different.
@TJ111Sep 19.2007 — #Felgall is right in that they aren't variables. They are constant form values, and get passed with the form the same as any other user type input. You can have them set as preset values written into the page, or use some sort of scripting (server-side or client side, ie. PHP/javascript) to define the values.
@ray326Sep 19.2007 — #I'm not sure "constant" is the right term for them. Their values can be changed via scripting on the page and they are used that way quite often.
@TJ111Sep 19.2007 — #lol I'm not one for always using the proper terminology, but I can clarify. They are essentially equivalent to other <inputs> in functionality, except that you control their value, not the user.
@felgallSep 19.2007 — #I'm not sure "constant" is the right term for them. Their values can be changed via scripting on the page and they are used that way quite often.[/QUOTE]
You can change any of the HTML from JavaScript - that doesn't make the entire HTML a variable. The value may be a variable in JavaScript but it is a contant in HTML because HTML does not provide a way to change it.
@KravvitzSep 20.2007 — #It's not quite the same. If I remember correctly, some browsers won't include form controls that have display:none when you submit the form.