This BotDetect Captcha PHP code example shows how to configure Captcha challenges by setting Captcha
object properties in PHP form source.
Multiple PHP forms within the same PHP website can be protected by BotDetect Captcha challenges: e.g. you could include botdetect.php
in both your Contact form and Registration form source.
To function properly, separate Captcha challenges placed on each form should have different names (CaptchaId
values sent to the Captcha
object constructor, Captcha1
and Captcha2
in this example), and can use completely different Captcha settings.
Even multiple Captcha instances placed on the same form won't interfere with each other's validation and functionality. And if a user opens the same page in multiple browser tabs, each tab will independently validate the shown Captcha code.
Shared Captcha settings should always be placed in the CaptchaConfig.php
application configuration file, and only diverging settings set through Captcha object instance properties in form code, to avoid code duplication.
Settings that affect only Captcha container markup generation take effect immediately (changing $Captcha->Html
output), but settings that affect Captcha challenge (image or sound) generation in separate Http requests need to be saved in PHP Session state when set through Captcha
object instance properties in form source, consuming server resources and reverting to defaults when the PHP Session expires.
Please note that if configured values are dynamic (e.g. CaptchaRandomization
helper or other function calls in form code), they will be re-calculated only when the form is reloaded (form code is executed). For example, Captcha ImageStyle
randomized in PHP form source will not change on each Captcha Reload button click, but only on each form load.
BotDetectâ˘
trademark in the background of 50% of all Captcha images generated.These limitations are removed if you upgrade your BotDetect license.
BotDetect PHP Captcha Library version 4.1.0 Free loaded by PHP version 7.2.34-38+ubuntu18.04.1+deb.sury.org+1