Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send hidden data

Tags:

html

forms

hidden

I have a form(like the one below for example) where I type data, but I also want to send data which are not directly entered by the user, for example a generic Id(for a user in this case)

<form name="input" action="" method="post"> Username: <input type="text" name="user"> <input type="submit" value="Submit"> </form> 

Don't know if I have been clear enough, I hope so.

like image 337
user2556079 Avatar asked Jul 06 '13 18:07

user2556079


People also ask

Is input type hidden safe?

Since they are not rendered visible, hidden inputs are sometimes erroneously perceived as safe. But similar to session cookies, hidden form inputs store the software's state information client-side, instead of server-side. This makes it vulnerable.

How do hidden fields work?

Hidden Fields are a Free feature allow you to use data that you already have, track information about your respondents, and make your typeforms more personal. Hidden Fields can be used for lots of things: Track the source of respondents (social media channels, for example)

How do you send a hidden input?

The <input type="hidden"> defines a hidden input field. A hidden field lets web developers include data that cannot be seen or modified by users when a form is submitted. A hidden field often stores what database record that needs to be updated when the form is submitted.


1 Answers

try a hidden input:

<input type="hidden" value="foo" name="user_id" /> 

The user can't see it, but remember that such inputs can be spoofed and need to be validated on the server just like any other input.

like image 181
Mgetz Avatar answered Oct 06 '22 05:10

Mgetz