<?php
session_start();
include_once('class.ReloadPreventer.inc.php');
$rp = (object) new ReloadPreventer;
if (isset($_POST['testform_button'])) // only check if form is submitted
{
if ($rp->isValid() == true) // check if tokens match up
{
$message = (string) 'Input OK';
}
else
{
$message = (string) 'Data sent twice';
} // end if
} // end if
$rp->setTokenSession(); // Set new token after old token was checked
?>
<html>
<head>
<title>Sample</title>
</head>
<body>
<p><b><?php echo $message; ?></b></p>
<p><?php echo $_POST['teststring']; ?></p>
<form name="token" action="index.php" method="post">
<input name="teststring" type="text" value=""><br>
<input type="submit" value="Send" name="testform_button">
<input name="<?php echo $rp->getFormName(); ?>" type="hidden" value="<?php echo $rp->getToken(); ?>">
</form>
</body>
</html>
|