June 21st, 2013, 05:31 PM
Hidden Field !
Why we use hidden field in PHP ..... I am stuck here why we do this? please help
June 21st, 2013, 05:38 PM
I don't think you know what you're talking about.
How about writing something longer than just a sentence? What "hidden field" are you referring to? Stuck doing what?
June 21st, 2013, 05:58 PM
If you're referring to HTML form "hidden" fields, those really don't have anything to do with PHP. PHP doesn't care if the value comes from a hidden field, a text field, a select box, a textarea, a checkbox, etc.
Originally Posted by ionezation
If you're unsure of the value of "hidden" form fields then that's more a UX (user experience) question.
June 22nd, 2013, 03:37 AM
Originally Posted by dmittner
sorry for not mentioning it ... I was talking about the hidden text field of HTML .. I am not getting clear why we use it in anyway !
June 22nd, 2013, 08:56 AM
I think I used for for fields to set perhaps a default value if the user does not select one from perhaps a radio button or checkbox. It can also be used as an identifier. Let's say you have 1 form to be used in multiple ways. When PHP builds the form and hands it to the client, it may define a hidden field's value as "support", "request", or "bug". This way when submitted, the PHP that will process the file knows the intent on the submission, and can file it differently.
June 22nd, 2013, 09:33 AM
hidden fields are simply used for any data you wanna send along with the user-defined values. In other words, hidden fields hold preset values that are not supposed to show up in a visible form element like a text container, a checkbox or whatever.
A classical example would be the "add to cart" button in an online shop: If you're using plain HTML (no AJAX), you'd implement this as a POST form. The user can enter a quantity, click on "add", and then the product gets added to the shopping cart. And how do you know which product that was? By putting the product ID into a hidden field.
Note, however, that hidden fields are not safe from being seen or changed (no form element is). So this is not a security feature.
June 23rd, 2013, 03:54 AM
Thanks for reply friends ... it means its not safe to use them at all?
June 23rd, 2013, 05:05 AM
What I was trying to say is that hidden fields are not safer than, say, a text field.
Some people think that hidden fields can't be edited, since they're not being rendered in the browser. But any user can send you any form data they want, regardless of what your HTML form looks like. You cannot rely on any user input.
June 23rd, 2013, 10:49 AM
Yep, so it's not saying don't use them cuz they're not safe, but don't use them as a safely measurement. They just don't appear visual on the page, but they are still there. Just more a hidden note than anything.
Comments on this post
June 24th, 2013, 11:20 AM
Originally Posted by Triple_Nothing
Is there any alternate for hidden fields ? I little difficult for me ... there must be a way for it?
June 24th, 2013, 11:39 AM
An alternative to achieve what goal?
Originally Posted by ionezation
They're the easiest way to pass form input into your PHP that you don't want the end user to see. And they're as good for that purpose as they need to be. An alternative usually isn't necessary...
June 25th, 2013, 03:32 AM
alternative to hidden fields? cookies/session and an extreme storing it in a database & getting the values in the next page..