About Hidden field form

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

phpneebie
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Feb 25, 2013 3:43 pm

About Hidden field form

Postby phpneebie » Tue Apr 23, 2013 4:11 am

Hi All,

I would like to find out the purpose for form.

Example: input type="hidden" value""

So what do value means?
What should this value be?
And when to use it?

Hope someone can advice, thanks.

Regards,
Phpnewbie

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: About Hidden field form

Postby johnj » Tue Apr 23, 2013 5:54 am

'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>

phpneebie
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Feb 25, 2013 3:43 pm

Re: About Hidden field form

Postby phpneebie » Tue Apr 23, 2013 10:26 am

Thanks for your reply.

So can we say that the value is just for the server to understand which form we submitting right?

And we only use this when there is a lot of form usage in our web right?

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: About Hidden field form

Postby seandisanti » Tue Apr 23, 2013 11:29 am

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.

User avatar
Strider64
New php-forum User
New php-forum User
Posts: 70
Joined: Sat Mar 23, 2013 8:24 am

Re: About Hidden field form

Postby Strider64 » Tue Apr 23, 2013 1:18 pm

Rule of Thumb -> Never trust anything that a user might alter or might be able to alter period.

phpneebie
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Feb 25, 2013 3:43 pm

Re: About Hidden field form

Postby phpneebie » Wed Apr 24, 2013 6:55 am

thanks all for advice.

By the way, can anyone advice me if develop a membership
site that required sign up, login, member profile,

what is the first thing required till last?

e.g. 1. under process.php file will have code to connect to database, create table,
then maybe also vadliate form, insert to database, confirmation email

Therefore if is like what I want to create, is there anything else?

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: About Hidden field form

Postby seandisanti » Thu Apr 25, 2013 7:26 am

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.

HussainMHB
New php-forum User
New php-forum User
Posts: 10
Joined: Sat Apr 13, 2013 2:53 am

Re: About Hidden field form

Postby HussainMHB » Sat Apr 27, 2013 10:23 am

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

johnmacd
New php-forum User
New php-forum User
Posts: 19
Joined: Wed Jun 12, 2013 9:30 pm
Contact:

Re: About Hidden field form

Postby johnmacd » Thu Jun 13, 2013 11:42 pm

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.


Return to “PHP coding => General”

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 4 guests