Protect your website from spam and abuse while letting real people pass through with ease.
The new reCAPTCHA is here. A significant number of your users can now attest they are human without having to solve a CAPTCHA. Instead with just a single click they’ll confirm they are not a robot. We’re calling it the No CAPTCHA reCAPTCHA experience.
How to Install/use reCAPTCHA in website? here i will explain step by step instruction:
STEP 1:
Go to : https://www.google.com/recaptcha/intro/index.html and click on ‘Get reCAPTACHA’ . and fill the form and complete it.
STEP 2:
Now you can see one reCAPTCHA added on you list. just click on it.
STEP 3:
here is you all secret and detail.
STEP4:
Now use in form: HTML Form
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <script src='https://www.google.com/recaptcha/api.js'></script> <form role="form" id="form1" name="form1" method="post" action="thankyou"> <div style="margin-bottom:10px;"> <label style="font-weight:normal;">Name:</label> <input name="name" type="text" style="width:100%;" class="form-control" required placeholder="Your Full Name" id="name"> </div> <div style="margin-bottom:10px;"> <label style="font-weight:normal;">Email:</label> <input type="email" name="email" required placeholder="Enter a valid email address" class="form-control" style="width:100%;"> </div> <div style="margin-bottom:10px;"> <label style="font-weight:normal;">Phone Number:</label> <input name="phone" type="text" class="form-control" style="width:100%;" required placeholder="Your Contact Number" id="phone"> </div> <div style="margin-bottom:10px;"> <label style="font-weight:normal;">Message:</label> <textarea name="msg" class="form-control" required style="width:100%; height:200px;" id="msg"> </textarea> </div> <div style="text-align:left;"> <div class="g-recaptcha" data-sitekey="YOUR-SITE-KEY"></div> </div> <div> <input name="act" type="hidden" id="act" value="send" /> <input type="submit" name="button" id="button" value="SUBMIT" class="btn btn-success" style="font-size:16px;" /> </div> </form> |
STEP5:
Submit.php / Form Processing in PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | <?php if(isset($_POST['email']) && !empty($_POST['email'])) { if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])) { //your site secret key $secret = 'YOUR-SECRET-KEY'; //get verify response data $verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']); $responseData = json_decode($verifyResponse); if($responseData->success){ //contact form submission code $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $msg=$_POST['msg']; $date=date('d-m-Y H:i:s'); $readed="no"; $read_date="no"; $email_to = "info@xyz.com"; $email_subject = "Email From Melea Website"; $message = "\n\nName: ".$name. "\n\nEmail: ".$email. "\n\nPhone: ".$phone. "\n\nMessage: ".$msg."\n\n"; // create email headers // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= "X-Priority: 3\r\n"; $headers .= "X-Mailer: PHP". phpversion() ."\r\n"; // More headers $headers .= "Reply-To:info@xyz.com\r\n"; $headers .= "Return-Path:info@xyz.com\r\n"; $headers .= 'From:info@xyz.com' . "\r\n"; $mail_sent=@mail($email_to, $email_subject, $message, $headers); // insert in to DB $name2=htmlspecialchars($_POST['name'],ENT_QUOTES); $email2=htmlspecialchars($_POST['email'],ENT_QUOTES); $phone2=htmlspecialchars($_POST['phone'],ENT_QUOTES); $msg2=htmlspecialchars($_POST['msg'],ENT_QUOTES); $insert=mysql_query("INSERT INTO contact(name,email,phone,msg,date,readed,read_date) VALUES ('$name2','$email2','$phone2','$msg2','$date2','$readed2','$read_date2')"); echo"<div class='alert alert-success'>Thank You! We will get back to you as soon as possible!</div>"; } else { $errMsg = "<div class='alert alert-danger'>Robot verification failed, please try again.</div>"; } } else { $errMsg = "<div class='alert alert-danger'>Please click on the reCAPTCHA box.</div>"; } echo"$errMsg"; } ?> |