Concerning the use of hidden in <input>
As I continue to learn HTML and PHP there is one thing I'd just do not understand. You create a <form>, build the various input types, 'text', 'password', etc and usually a 'submit' type. Then you build another input type of 'hidden', with accompanying name and value attributes.
In the PHP code you then issue an if (isset($_POST['name attribute'])), which checks the name attribute of the hidden type.
Why use the hidden attribute? You can just as easily use the name attribute of the submit type?
I'm I missing something here?
Originally Posted by CanMike
“The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
—Tim Berners-Lee, W3C Director and inventor of the World Wide Web
Thanks for taking the time to answer.
I kind of understand the concept of 'save state', but given two input statements:
<input type='submit' name='submit' value='Login' />
<input type='hidden' name='submitted' value='TRUE' />
my PHP code checks
$name1 = $_POST['submitted'];
$name2 = $_POST['submit'];
echo $name1; --> displays 'TRUE'
echo $name2; --> displays 'Login'
require_once('./includes/mysql_connect.php'); // Connect to db.
Isn't the 'save state' simply the value of $_POST variable?
Also the submit button may not be passed with the form if the form is submitted without actually clicking on the button but by some other means. Only currently selected buttons are passed with the form.
OK, now I starting to get it. You can hold a value to be used, even if the button is not used.
I use it for a value brought forward from a previous page, and being carried on to the next, along with a value input from the present page, in php.
Last edited by kiwibrit; 06-14-2006 at 08:07 PM.
Reason: clarification (I hope)
Now it all make sense.
See, us old Oracle DBA's, COBOL/Java/ & PL/SQL developers can learn new trick if you hit us over the head hard enough.
I say, bring back green screens!
A web browser is just a 3270 with lipstick. Check out this form handler for a very common use of hidden fields.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan
Never thought about it quite that way before but I think that description is very accurate.
Originally Posted by ray326
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)