uses of hidden fields

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adsegzy
Forum Contributor
Posts: 184
Joined: Tue Jul 28, 2009 9:26 am

uses of hidden fields

Post by adsegzy »

Hello there,

I always see hidden fields use in forms and i will like to ask, what is it meant for and what are the advantages.

Regards
Kurby
Forum Commoner
Posts: 63
Joined: Tue Feb 23, 2010 10:51 am

Re: uses of hidden fields

Post by Kurby »

Hidden fields can be used as a way of passing data between webpages and maintaining their values. For example, a shopping cart could have you enter your address on one page and your credit card on another. Page 2 will have hidden fields containing the address that you entered previously. Hidden fields are read with PHP the same away any other field is, its just not visible to the user and therefore won't be changed.

There are other uses as well such as storing a checksum of some kind, to ensure that the origin of posted data is where your script expects it to come from.
Phoenixheart
Forum Contributor
Posts: 123
Joined: Tue Nov 16, 2004 7:46 am
Contact:

Re: uses of hidden fields

Post by Phoenixheart »

Just a slight notice, a hidden field's value can be changed easily using an inspector (like Firebug). So don't rely on it as a security method in any way.
In other words, as a developer, treat hidden fields exactly as other fields.
Post Reply