A hidden field is form control that is not displayed to the user. As such, it can be used to hold a value that acts as state on a web page and allows values to persist between multiple calls to web pages. In the example below, we have a simple integer value that is stored in _POST['i'] and incremented each time the submit button is pressed.
Of course, pressing the submit button refreshes the entire page as well as incrementing the value.
<html> <head><title>Hidden Fields</title></head> <body> <?php if (!isset($_POST['i'])) { $_POST['i'] = 1; } else { ++$_POST['i']; } ?> <form action="Hidden.php" method="post"> <p><?php echo $_POST['i'] ?></p> <input type = "hidden" name="i" value="<?php echo $_POST['i'] ?>" /> <input type="submit" /> </form> </body> </html>
© 20072024 XoaX.net LLC. All rights reserved.