I am creating a form using dreamweaver cc. the form is written in php and working good. now i want to add captcha image or text for verification method. how to possible using my code to add a captcha.
My form looking like this
<table width="100%" border="1" align="center" cellpadding="2">
<form method="post" action="contact_process.php"><tr>
<td><input type="text" name="name" placeholder="Enter Name" class="add_input_data" required/></td>
</tr>
<tr>
<td><input type="text" name="mobile" placeholder="Enter Mobile" class="add_input_data" required/></td>
</tr>
<tr>
<td><select name="location" class="add_input_data">
<option selected disabled>Location</option>
<option value="chittore">Chittore</option>
<option value="koduru">Koduru</option>
<option value="other">Other</option>
</select></td>
</tr>
<tr>
<td><textarea name="address" class="add_input_textarea" placeholder="Enter Address" required></textarea></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Submit" class="add_input_submit" align="right"/></td>
</tr></form>
</table>
my form processing script is looking like this
<?php
$name = $_POST['name'];
$mobile = $_POST['mobile'];
$location = $_POST['location'];
$address = $_POST['address'];
$formcontent="From: $name \n Mobile : $mobile \n Location: $location \n Address : $address";
$recipient = "dovariramu@gmail.com";
$subject = "New Connection Query";
mail($recipient, $subject, $formcontent) or die("Error!");
header('Location: thankyou.php');
?>
and my thankyou.php page with some content. here i am not showing.
Now I have two questions
1) when a user fill the data and click the submit button, the form display success full message from thankyou.php. but i want to display success full message with in a page(with simple scrolling success full message). 2) I want to add a captcha for this form. How to do this ?
captcha code tutorial HERE.This solve my problem .
For make this simple use the following php code
ITS 100% WORK TRY It, copy div tag & past in html and do follow the code......
captcha.php file
The simplest way to add a CAPTCHA is to use google's new reCaptcha. Its simple to use you just need to register at https://www.google.com/recaptcha/ and get a site key and a secret code. I am using this on my website and it works well. After registration you will have to add a simple div element where you want the CAPTCHA to render.and a simple code to implement it that you can find here.
for captcha you used,
rand()
method like:In html, write
And now you can match both values
( $c with $("#txt_value").val() )
in jquery or on form submission, whatever make you easy.Hope it helps...