PHP Simple Math Captcha
Hi Guys in This lesson we are going to learn how to create simple captcha system in php. follow the below example to learn php simple captchaCreate file index.php
copy the below codes and run it..
1. index.php
<?php session_start(); if(isset($_POST['submit'])){ if($_POST["captcha"]==$_SESSION["captcha"]){ $message= "<b><font style=color:green size=4>Your Captcha is Correct</font></b>"; }else{ $message="<b><font style=color:red size=4>Incorrect Captcha</font></b>"; } } ?> <style> input[type=text]{ padding:4px; border-radius:4px; } input[type=submit]{ padding:5px; border-radius:4px; background:black; color:white; } </style> <h2>PHP Simple Math Captcha</h2> <form method="POST"> <table> <tr> <td></td> <td> <?php $captcha=mt_rand(4444,6444); $_SESSION['captcha']=$captcha; echo '<b><font style=color:indigo size=5>' . $_SESSION['captcha']. '</font></b>'; ?> </td> </tr> <tr> <td></td> <td><input type="text" name="captcha"/></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="Validate"/></td> </tr> </table> </form> <?php if(isset($message)){ echo $message; }?>
That's it guys how to create simple captcha system in php ..
No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.