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: 20 years ago
Size: 931 bytes


Class file image Download
$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';
$message = (string) 'Data sent twice';
// end if
} // end if

$rp->setTokenSession(); // Set new token after old token was checked
        <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(); ?>">