Simple captcha with PHP, We seen how to create a Simple captcha . Now we look how to integrate that simple Captcha with HTML Form. Now I am going to show you a Newsletter Subscriber with our Simple Captcha.
Simple captcha with PHP and Live Example with Newsletter
Let me create a HTML form look like this
<?php
Simple captcha with PHP and Live Example with Newsletter
- Show an image Captcha without any dependancies, such as Class, Function etc.,
- Customizable code length, character sets, and Unicode support
- TTF font support
- Easily customization: Background and Foreground colors
Let me create a HTML form look like this
<?php
session_start();
if(isset($_POST['subscribe']))
{
$email=$_POST['email'];
if(!preg_match('/([\w-\.]+)@((?:[\w]+\.)+)([a-zA-Z]{2,4})/',$email))
{
$response="Invalid Email Address";
}elseif(strcmp($_SESSION['capcha_code'],$_POST['code'])!=0)
{
$response="Invalid Verfification Code";
}else
{
//Save Email address
$response="Subscribed! Thank you !";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Capcha : Example Form</title>
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Geneva, sans-serif;
font-size: 11px;
color: #333;
}
body {
margin-left: 10px;
margin-top: 10px;
}
-->
</style></head>
<body>
<form action="" method="post" name="subscribe">
<table border="0" cellspacing="0" cellpadding="5" style="border:1px solid #CCC;">
<tr>
<td colspan="2" bgcolor="#D6D6D6"><b>Subscribe Newsletter</b></td>
</tr>
<tr>
<td>Email Address</td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td>Antibot</td>
<td><input type="text" name="code" id="code" value="Enter code here" onFocus="this.value=''"></td>
</tr>
<tr>
<td> </td>
<td>
<img src="capcha_image.php" alt="Verify" width="75" height="25" style="border:2px solid #000;"></td>
</tr>
<tr>
<td> </td>
<td><input name="subscribe" type="submit" id="subscribe" value="Subscribe"></td>
</tr>
<tr>
<td colspan="2">
<?php echo @$response; ?>
</td>
</tr>
</table>
</form>
</body>
</html>
|

No comments:
Post a Comment