Page 1 of 1

Re: About Hidden field form

Posted: Tue Apr 23, 2013 5:54 am
by johnj
'type' equal to 'hidden' means that particular form input will not show up to the user but all details of this input will be passed to the server when this form is submitted.

value is whatever you want to be passed to the server for that particular input. value could 'hello' or '1' or '1999A' etc etc

When do we use this? suppose I have 2 forms, form1 and form2. How do we decide which form was submitted?. For this, we'll use a input type as hidden, name as 'form_type' and value as 'form1' when we submit the first form, and value as 'form2' when we submit the second form. In this way, we know which form are we dealing with. e.g.

Code: Select all

<form>
<input type="hidden" name="form_type" value="form1" />
</form>

Re: About Hidden field form

Posted: Tue Apr 23, 2013 11:29 am
by seandisanti
No, you can use it to pass any type of data from a form to a form processor without putting it into an editable input that the visitor can easily edit. That said, you can't assume values passed via hidden input are any safer than any other user input.

Re: About Hidden field form

Posted: Tue Apr 23, 2013 1:18 pm
by Strider64
Rule of Thumb -> Never trust anything that a user might alter or might be able to alter period.

Re: About Hidden field form

Posted: Thu Apr 25, 2013 7:26 am
by seandisanti
phpacademy.org has a video series covering exactly that in their tutorials. One thing i would warn though, it is kind of an older series, so it uses some deprecated functions, specifically the mysql_ library. Follow the tutorial, but do it for the concepts, not necessarily the code. The first thing you should do upon successful completion of the course is go through and modernize your code, including changing the database interaction from mysql_ to PDO. If you run into issues, def ask either here or there, that site has a forum also but it's not a standard phpBB, and it has some glitches.

Re: About Hidden field form

Posted: Sat Apr 27, 2013 10:23 am
by HussainMHB
Well! Great time to see this post and thanks for all for making this and replying to this. I've been having problem regarding this i got to use two buttons and text box and need to write two coding in two way based on the process. But i don't know that fully. Hidden would be help me. I'll try this

Re: About Hidden field form

Posted: Thu Jun 13, 2013 11:42 pm
by johnmacd
The use of hidden fields is we can pass data to the server without showing it to the user.
Syntax is-<input type="hidden" name="form_type" value="100" />
In the above example value=100.we can pass this value to the server or on next form.