Login   Register  
PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 2002-11-19 21:04
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>