Web www.gerd-tentler.de
Version 1.3 (released Dez. 31, 2016) [Download]

Usage

Add an extra form field to your message form like this:
<input type="text" name="secCode"> <b>&laquo;</b>
<img src="seccode.php" width="71" height="21" align="absmiddle">
Sec-Code stores the security code in a session variable, so don't forget to start a session in your script where you validate the security code. This has to be done before any headers are sent:
if(!session_id()) session_start();
Here's an example how you can check for a valid security code:
if($_POST['secCode'] != $_SESSION['secCode']) {
  // wrong security code
  ...
}
else {
  // security code is valid; reset it!
  $_SESSION['secCode'] = rand(100000, 999999);
  ...
}
If the security code is valid, it should be resetted to make sure that it can't be used again.

Comments