I have a website where I use form fields very often. I get an error in the client-side installation. I want to make a server-side installation, but I could not find a document for this. Could you help me?
Hey,
I’m not too sure what you’re asking. You will need to insert some stuff client-side (to load Turnstile) but the validation will always be done server-side.
I’d recommend checking the docs: Get started · Cloudflare Turnstile docs
If you’re still having issues after, please send the code you’re currently using, the error you get and what you’ve tried so far.
This is what i did…Not sure if it is the best way, but it worked for me.
$captcha=$_POST['cf-turnstile-response'];
if (!$captcha) {
// What happens when the CAPTCHA was entered incorrectly
echo '<h2>Please check the the captcha form.</h2>';
exit;
}
$secretKey = "xxxxxxxxxxxxxxxxxxxxx";
$ip = $_SERVER['REMOTE_ADDR'];
$url_path = 'https://challenges.cloudflare.com/turnstile/v0/siteverify';
$data = array('secret' => $secretKey, 'response' => $captcha, 'remoteip' => $ip);
$options = array(
'http' => array(
'method' => 'POST',
'content' => http_build_query($data))
);
$stream = stream_context_create($options);
$result = file_get_contents(
$url_path, false, $stream);
$response = $result;
$responseKeys = json_decode($response,true);
//print_r ($responseKeys);
if(intval($responseKeys["success"]) !== 1) {
echo '<h2>spam?</h2>';
} else {
//Put your mail code here
}
Adblock plugins block “/turnstile/v0/api.js”. This makes me feel that the protection is not working. When I uninstall the adblock plugin and try it, a console error occurs.
do you want to implement this in plan php form or with any framework or cms?
you can simple follow the steps as state here
https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/
Thanks I wasted hours not using a post. So dumb they require a post.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.