PHP Simple Math Captcha - Web Development and Online Earning

Breaking

Web Development and Online Earning

Learn Web Development ,PHP MySQL,Codeigniter,AJAX,HTML CSS,Javascript,Jquery,Web Hosting,Online Earning,SEO,Link Building,Online Banking,Online Earning,Wordpress,Windows Tips,Web Design Tutorials...

test banner

Post Top Ad

Responsive Ads Here

Post Top Ad

Responsive Ads Here

Wednesday, May 31, 2017

PHP Simple Math Captcha

PHP Simple Math Captcha Validation

PHP Simple Math Captcha
PHP Simple Math Captcha

Hi Guys Today we will Learn How To Validate Numeric Captcha using PHP SESSION.
It's Easy and Simple .This Codes is Beginners Friendly it will Help User to Understand Basic Captcha System.
What You Will Needs:
Create 3 files named are given below.
1.index.php
2.captcha.php
3.style.css

PHP Simple Math Captcha
PHP Simple Math Captcha
Now Copy the below codes for Certain Files .
index.php
Add the below PHP Codes top of the index.php page to process and validate captcha.
<?php
session_start();
if(isset($_POST['submit'])){
if($_POST["captcha_code"]==$_SESSION["captcha_code"]){
$success="Your Captcha successfully Validate";
}else{
 $error= "Wrong Captcha.Please Type Valid Captcha";
}

}

?>

Now Add the Below html codes after the PHP Codes to Display form.
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css"/>
<title>Simple SESSION Based Math Captcha with PHP </title>
</head>
<div id="form">
<h2 color="black">PHP Simple Math Captcha Validation</h2>
<form method="post" action="">
<font size="20px" color="green"><?php include('captcha.php');?></font><br/>
<input type="text" name="captcha_code" placeholder="Enter The Numbers"/><br/>
<input type="submit" name="submit" value="Validate"/>
</form>
<span><?php if(isset($error)){echo $error;}?></span>
<success><?php if(isset($success)){echo $success;}?></success>
</div>
</html>

captcha.php
use The Below codes for captcha.php to Generate Random Captcha With SESSION.
<?php
$captcha=mt_rand(111,666);
echo $captcha;
$_SESSION['captcha_code']=$captcha;
?>

style.css
Now add some CSS codes to Beautify our Index page.
#form{
 width:600px;
 height:250px;
 background:#ddd;
 color:black;
}
input[type=text]{
 padding:7px;
 width:50%;
 border-radius:5px
}
input[type=text]:focus{
 border:2px solid black;
 padding:8px;
}
input[type=submit]{
 padding:5px;
 border-radius:5px;
 background:#080808;
 color:white;
}
label{
 font-size:20px;
 color:black;
 font-weight:bold;
}
success{
 font-size:20px;
 color:green;
 font-weight:bold;
}

span{
 font-size:20px;
 color:red;
}

Now You have Successfully Created PHP SESSION Based Captcha Validation System.
Thank you for Visit.

1 comment:

Thank You for Your Comment

Post Top Ad

Responsive Ads Here