Hi,
In this post I will give a very basic sample of creating your own captcha, with font, shape and size of your own choice. To achieve this we need the GD library to be enabled for you apache server. In this you need to create two php files and use a ttf file.
First we create the index.php file as follows:
<?php
session_start();
if(isset($_POST['captcha']))
{
if($_POST['captcha']==$_SESSION['captcha_code']){
echo "<font color='green'>Captcha code matched</font>";
}else{
echo "<font color='red'>Incorrect captcha code</font>";
}
echo "<br/>";
}
?>
<form action="" method="post">
<img id="captcha" src="captcha.php" /><br/>
<a href="javascript: void(0)" onclick="document.getElementById('captcha').src='captcha.php'">choose a different word</a>
<br/>
<input type="text" name="captcha" />
<input type="submit" value="Submit">
</form>
In this post I will give a very basic sample of creating your own captcha, with font, shape and size of your own choice. To achieve this we need the GD library to be enabled for you apache server. In this you need to create two php files and use a ttf file.
First we create the index.php file as follows:
<?php
session_start();
if(isset($_POST['captcha']))
{
if($_POST['captcha']==$_SESSION['captcha_code']){
echo "<font color='green'>Captcha code matched</font>";
}else{
echo "<font color='red'>Incorrect captcha code</font>";
}
echo "<br/>";
}
?>
<form action="" method="post">
<img id="captcha" src="captcha.php" /><br/>
<a href="javascript: void(0)" onclick="document.getElementById('captcha').src='captcha.php'">choose a different word</a>
<br/>
<input type="text" name="captcha" />
<input type="submit" value="Submit">
</form>
Now the second file you need is the captcha.php, which is as follows: