Jump to main content
University Computer Centre
Extension Modules for websites
<?php require_once('../config.inc.en');

require_once('php/secform.inc');
# 1. initialize method:  # 2 – token, time check and
# JavaScript checkbox: "I'm human" - visible, JavaScript required
$secform = new tucal_secform(2);

seite(__FILE__);

if (isset($_POST['email'])) {
    # 3. Form evaluation
    # time for the user to fill in the form in seconds: min, max
    list($ok$reason) = $secform->check_token(5900);
    if ($ok) {
        # general form evaluation
        echo '<p>Ok</p><ul><li><a href="mod_secform2.php.en">back to this example</a></li>';
        echo '<li><a href="../secform.html.en#ex">back to list of all examples</a></li>';
        echo '<li>Check: Reloading the page should be detected</li></ul>';
        return;
    } else {
        # output error, e.g. $reason, and/or simply display form again
        echo 'Error: ' htmlspecialchars($reason);
    }
}
# Empty form:
?>

<h1 class="linie">Form</h1>

<form action="mod_secform2.php.en" method="post" class="form-horizontal">
  <div class="form-group">
   <label for="EMail" class="col-xm-3 control-label">E-mail address</label>
   <div class="col-xm-9">
    <input type="email" class="form-control" id="EMail" name="email" placeholder="name@domain">
   </div>
  </div>
  <div class="form-group">
   <div class="col-xm-offset-3 col-xm-9">
    <div class="checkbox">
     <label> <input type="checkbox" name="check"> Click me </label>
    </div>
 <?php echo $secform->get_token(); ?>
    <button type="submit" class="btn btn-default" style="margin:1em 0">Send</button>
   </div>
  </div>
</form>
<p><a href="../secform.html.en#ex">back to list of all examples</a></p>

Show output with this program code