logo
Tags down

shadow

php form with google captcha


By : navdeep singh
Date : May 05 2020, 10:15 AM

I try using Google reCAPTCHA and it was working very nice. but because of some issues I started to use php image CAPTCHA. CAPTCHA image rendered correctly but I can't validate it correctly.

I use this code to generate CAPTCHA

session_start();
if(isset($_SESSION['captcha_text']))
{
unset($_SESSION['captcha_text']);
}

$permitted_chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZ';
// ...
// code to generate CAPTCHA
// ...
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

then I show CAPTCHA using this code

<img src="CAPTCHA/captcha.php" alt="CAPTCHA" class="captcha-image"><i style="position: absolute;" class="refresh-captcha"></i><BR>
<input autocomplete="off" style="margin-top: 0.8rem;" type="text" id="captcha" name="captcha_challenge" pattern="[A-Z]{6}">

Now I validate CAPTCHA in another PHP file using  next code  :

session_start();
header('Content-Type: text/html; charset=utf-8', true);
if(isset($_POST['captcha_challenge']) && strtoupper($_POST['captcha_challenge']) == $_SESSION['captcha_text']) {
    echo '<p>You entered a correct Captcha.</p>';
} else {
    echo '<p>You entered an incorrect Captcha.</p>';
}

$_SESSION['captcha_text'] = NULL;
unset($_SESSION['captcha_text']);
exit;

untill now it worked correctly. I test it manually and it works. But when I use some security scripts to test forms, I get spam. why?? what I missed?? <--sorry for my bad English-->

Answer :

OK After searching internet I decided to go back to Google reCaptcha and try to fix display problems that occure in my website with reCaptcha.

Rather than try to reinvent the wheel, just save yourself the hassle and use Google reCaptcha.



Share : facebook icon twitter icon
Related Posts Related Posts :
  • clear array after form submit
  • pass url variable to javascript
  • access data using api
  • div position fixed css
  • add horizontal line between two div
  • disable toggle button css
  • css fixed line height
  • background image not working
  • table cell border
  • text line break css
  • overlay div on div
  • text direction rtl css
  • javascript convert string to an object
  • bind inner div click to outer div
  • jquery ajax oncomplete
  • how to use promise in for loop
  • jquery get element using variable
  • javascript send textbox value
  • pass div class content to another class or id
  • css new line after element
  • css calc not working properly
  • link disabled jquery
  • sql join table to subquery
  • MS Access SQL Issue with OR AND Operators
  • set textarea value using php
  • php merge two arrays into one
  • update current row in php
  • php date format mysql
  • mysql pdo select query
  • php function return an array
  • PHP mysqldump database to sql file
  • display image query
  • php create array using foreach loop
  • associative array php
  • group_concat in mysql laravel
  • php array_push empty
  • mysql on update cascade not working
  • pdo insert prepared statement
  • mysql insert ignore vs on duplicate key
  • mysql insert into existing row
  • mysql multi insert query
  • mysql group by show all rows
  • php change profile image
  • combine multiple arrays into one array php
  • how to sum values in an array
  • how to get sum of the total time
  • How to Create Facebook live stream without notification using API ?
  • on button click make div visible
  • css affect another element on hover
  • insert line after paragraph word
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org