It is a simple PHP program to generate captcha for form validation. It can be integrated in any website for captcha generation. This project is based on converting text to image using PHP with help of GD. It create 4 character and converts it to image.
- Each 4 character have different font , random font from the set of 10 fonts.
- Each character has different colour, font size, orientation and position
- Final captcha has many lines with different orientation, size, position and colour.
- Clone this repository:
or click
git clone https://github.com/tarunk04/Captcha_Generator
Download ZIP
in right panel of repository and extract it. - Copy
captcha-generator
folder into the project directory. - Copy this line to HTML or PHP file of the project.
<div id="ae_captcha_api"></div>
- Copy this script import line at the bottom of the body of same HTML or PHP file.
<script src="./captcha-generator/asset/main.js"></script>
- Create a form with a
Text Field
andButton
to send the user input to server usingPOST
method. - On server side use session variable
$_SESSION['secure']
for validating captch. For example:<?php session_start(); if($_SESSION['secure'] == $_POST['user_input']){ echo "captcha validated."; } else{ echo "captcha validation failed."; } ?>