BullGuard Antivirus Sale - 60% Off with openElement !
Forum openElement Homepage
Forum Home Forum Home >

openElement

> User Tutorials
  New Posts New Posts RSS Feed - Captcha test in PHP code (e.g. for SendForm)
  FAQ FAQ  Forum Search   Register Register  Login Login

Captcha test in PHP code (e.g. for SendForm)

 Post Reply Post Reply
Author
Message
Dmit OE View Drop Down
Admin Group
Admin Group
Avatar

Joined: 31 Mai 2012
Status: Offline
Points: 5276
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dmit OE Quote  Post ReplyReply Direct Link To This Post Topic: Captcha test in PHP code (e.g. for SendForm)
    Posted: 27 Oct 2015 at 15:58
Hi.

When you send form data using the Send Form element, you should process POST data yourself with some PHP code. If you add a Captcha to your form and want to test whether user entered a correct value, here's the code (it could have been much simpler but there are several bugs in the OE code, which will be fixed for next versions):

session_start();

// path from this page to the website root:
$pathToRoot = "/"; // change to "../" if this page is in a subfolder, "../../" if in a sub-subfolder etc.

global $OEConfWECaptcha;
require_once __DIR__ . "/" . $_SESSION['WECaptchaPage']."(var).php";
require_once __DIR__ . $pathToRoot . "WEFiles/Server/openElement.php";
require_once __DIR__ . $pathToRoot . "WEFiles/Server/DB/DBTools/OEDynUtils.php";


$captchaOk = OEDynUtils::IsCaptchaOk(); // test if user entered correct captcha

// echo $captchaOk ? "Ok" : "Wrong";

You can insert this code into a Code Block (Source) type PHP position StartDocument, or elsewhere.


Edited by Dmit OE - 27 Oct 2015 at 16:03
Back to Top
Dmit OE View Drop Down
Admin Group
Admin Group
Avatar

Joined: 31 Mai 2012
Status: Offline
Points: 5276
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dmit OE Quote  Post ReplyReply Direct Link To This Post Posted: 27 Oct 2015 at 16:05
P.S. For (future) versions later than 1.50R4, the code would be:

session_start();

// path from this page to the website root:
$pathToRoot = "/"; // change to "../" if this page is in a subfolder, "../../" if in a sub-subfolder etc.
require_once __DIR__ . "/" . $_SESSION['WECaptchaPage']."(var).php";
require_once __DIR__ . $pathToRoot . "WEFiles/Server/DB/DBTools/OEDynUtils.php";

$captchaOk = OEDynUtils::IsCaptchaOk(); // test if user entered correct captcha
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 10.11
Copyright ©2001-2012 Web Wiz Ltd.

This page was generated in 0,027 seconds.