PHP Classes

File: action.php

Recommend this page to a friend!
  Classes of Giorgos   Form Spam Bot Blocker   action.php   Download  
File: action.php
Role: Example script
Content type: text/plain
Description: an example of a protected form submission
Class: Form Spam Bot Blocker
Generate forms that prevent submission by robots
Author: By
Last change: v0.3
Date: 16 years ago
Size: 1,319 bytes


Class file image Download
$blocker=new formSpamBotBlocker();
$blocker->setTimeWindow(2,30); // set the min and max time in seconds for a form to be submitted
$blocker->setTrap(true,"mail"); // called here, because it has been called on the form page as well (same trap name!)
    if (
$_POST) $param=$_POST;
    elseif (
$_GET) $param=$_GET;
    if (!
$param) die("This script requires some POST or GET parameters from <a href=\"example.php\">example.php</a>");
if ($nospam==false) print "<p>This was an INVALID submission. You have acted like a spambot!</p>";
    else print
"<p>This was a VALID submission. Your message is: ".@$param['message']."</p>";
    if (
$submissions) print "<p>You have submitted ".$submissions." time(s). Reload this page to check...</p>";
<p>The names of the elements generated by the class as an array:<br />
<?php print_r ($blocker->getTagNames()); ?>
<p>The $_SESSION array generated by the class (if $hasSession==true):<br />
if ($blocker->hasSession) print_r ($_SESSION);
else print
"Session based methods have not been enabled";
<br /><a href="example.php">return to example</a>