Home > Form Elements > Hidden
Basic Attributes
<?php echo rand(1, 100); ?>
To set the value of the hidden field to a random number between 1 and 100.
<?php echo date('Y/m/d', time()); ?>
Would create a date timestamp in the format of: 2010/09/28.
This process does not include the use of $_SESSION fields! To use $_SESSION variables in your hidden field you will first need to assign the $_SESSION variable to a local PHP variable with something like this in the Page PHP Top Code area:
session_start();
$sample = $_SESSION['sample'];
You could make the value of the hidden field equal the session variable value with:
<?php echo $sample; ?>
unset($_SESSION['variable_name']);
In the Page PHP Footer Template Code part of your confirmation page or the variable will persist and possibly cause strange behavior!
You could also set other variables in the Page PHP Head Code field and display the value using the same technique. As an example, a reservation system might use PHP head code to query a database table for a reservation number, you would them echo that reservation number in this hidden field.
To generate a random number for the form submission, a timestamp, and so on.
So for example, if you use a Default Value of 'tester', our HTML would look like:
<input type="hidden" name="hidden0" id="hidden0" value="tester" />
F{field} = FIELD Elements (e.g. Form Items)
S{session} = SESSION
P{post} = POST
G{get} = GET
${php} = PHP
To access the named variable types. Please note the code is meant to output simple text values, not complex expressions. A typical example of code RackForms creates for a GET variable (G{}) is:
<?php if(isset($_GET['id'])) { echo $_GET['id']; } ?>