Thread: Hidden Field !

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    97
    Rep Power
    0

    Hidden Field !


    Why we use hidden field in PHP ..... I am stuck here why we do this? please help
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,994
    Rep Power
    9397
    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?
  4. #3
  5. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Originally Posted by ionezation
    Why we use hidden field in PHP ..... I am stuck here why we do this? please help
    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.

    If you're unsure of the value of "hidden" form fields then that's more a UX (user experience) question.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    97
    Rep Power
    0

    yes


    Originally Posted by dmittner
    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.

    If you're unsure of the value of "hidden" form fields then that's more a UX (user experience) question.

    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 !
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    676
    Rep Power
    7
    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.
  10. #6
  11. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Hi,

    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.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    97
    Rep Power
    0

    cool


    Thanks for reply friends ... it means its not safe to use them at all?
  14. #8
  15. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    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.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    676
    Rep Power
    7
    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

    • Jacques1 agrees
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    97
    Rep Power
    0

    cool


    Originally Posted by Triple_Nothing
    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.

    Is there any alternate for hidden fields ? I little difficult for me ... there must be a way for it?
  20. #11
  21. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Originally Posted by ionezation
    Is there any alternate for hidden fields ? I little difficult for me ... there must be a way for it?
    An alternative to achieve what goal?

    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...
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,971
    Rep Power
    375
    alternative to hidden fields? cookies/session and an extreme storing it in a database & getting the values in the next page..

IMN logo majestic logo threadwatch logo seochat tools logo