php script for captcha

CREATE OWN CAPTCHA FOR YOUR WEBSITE

Hi Geeks,
I am sharing you a program for creating a captcha script using php and javascript. Following are the simple steps to create captcha in php

Step 1: Create a php script named ‘captcha.php’ with following code that generate and return a captcha image.

Step 2: Now create a captcha.js file and put following code in the file.

Step 3: Now we need to create a Placeholder Element inside the form as following:

Step 4: Now after submitting you from validate the captcha was right or not. So in your form submit action use following code.

Note 1: In which page/form you are using the capcha , there should be session start in top of the file as following:

and also include the js file in your php page head section. jquery should be available before the captcha.js inclusion as following:

Note 2: PHP GD LIBRARY SHOULD BE INSTALLED ON YOUR SERVER.

 

Published by

Jeetendra Singh

Jeetendra Singh is a Full Stack Architect who has 12+ Years of Experience into Software Development. He is a Microsoft certified technology Specialist and AWS Certified Associate Architect. His Major Interests are in Mongo Db, Express Js, React Js, Node Js (MERN STACK), Python, DJango, Redis, Mysql, Dynamo DB , Devops, Jenkins, Cloud/Lamda , Fast Api. He build variety of applications using Python, Mern, Mean, Node, JavaScript, jQuery & PHP