PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of flaimo   Reload Preventer   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: example script
Class: Reload Preventer
Small class for preventing data being sent twice
Author: By
Last change:
Date: 21 years ago
Size: 931 bytes
 

Contents

Class file image Download
<?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>