BullGuard Antivirus Sale - 60% Off with openElement !
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


Joined: May 31 2012
Status: Offline
Points: 5283
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: Oct 27 2015 at 2:58pm
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 - Oct 27 2015 at 3:03pm
Back to Top
Dmit OE View Drop Down
Admin Group
Admin Group


Joined: May 31 2012
Status: Offline
Points: 5283
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dmit OE Quote  Post ReplyReply Direct Link To This Post Posted: Oct 27 2015 at 3:05pm
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 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.