Skip to main content

How to use google recaptcha with PHP

How to use google recaptcha with PHP


first sign up here(google recaptcha api).
The key pair consists of a site key and can download recaptcha file from google recaptch php library 


now  you will need to insert this code inside the <form> element where the reCAPTCHA widget will be placed:

  $publickey = "your_public_key"; // you got this from the signup page
  echo recaptcha_get_html($publickey);


    <body> <!-- the body tag is required or the CAPTCHA may not show on some browsers -->
      <!-- your HTML content -->

      <form method="post" action="verify.php">
          $publickey = "your_public_key"; // you got this from the signup page
          echo recaptcha_get_html($publickey);
        <input type="submit" />

      <!-- more of your HTML content -->
Step 3 
NOw you can check response by this code

//first i retrieved the recaptcha coming through post method.
//i have used post method, you can use any method you want.

$recaptcha = $_POST['g-recaptcha-response'];

//After retrieving send a post curl request to verify it.
//you will have to send your secret key along with it.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"secret=*******************************=".$recaptcha);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
$server_output = json_decode($server_output,true);
curl_close ($ch);

// captacha validated successfully.
// invalid captcha


Popular posts from this blog

How to do PHP unserialize jQuery serialized form data

How to do PHP unserialize jQuery serialized form data

  The Jquery serialize method just takes the form elements and puts them in string form. example - "firstvariable=value&secondvariable=othervalue";
if you are not using associative array then you can access this variable by $_GET and $_POST method.

Example = 
$variable1 = $_GET['firstvariable']; 

but if your data in an array then you need to unserialize jquery serialized data in php. you can unserialize jquery seralized data by usin this methods.

you can unserialize jquery serialize data into php by using parse_str.

$params = array(); parse_str($_GET, $params);//POST METHOD $params = array(); parse_str($_POST, $params);if your data serialize data in a variable then you need to use- $params = array(); parse_str($_POST['formdata'], $params);you can also use this function to unserialize your datafunction unserializeForm($str){ $returndata = array(); $strArray = explode("&",…

Solution-windows 'expo' is not recognized as an internal or external command

Solution forexpo is not recognized as an internal or external command,operable program or batch file in Windows 10Sometimes expo will not work globally mostly in windows 10, If you are facing same issue then follow the below Steps
1) Click on windows button and search for "Environment variables" and click on "Edit the system environment variables"

2) Now you will see a popup like below screen. Then you need to click on Environment Variables. (Please see highlight part in below image)

3)Then click on new button that i have highlighted in below image

4. Then a popup will open and you need to fill details like below mentioned
Variable Name :Path
Variable Value: %USERPROFILE%\AppData\Roaming\npm

Here we are creating a new path variable and passing location of npm.

Now Click on ok and close all the terminal windows and open new cmd and type Expo . Great now you can access expo from any location . Thanks

This solution is well tested with windows 10.

Android studio kotlin java change status bar color

Android studio kotlin/java change status bar background color

Hello Today we learn how to change status bar background color in android studio.
What is status bar ? In android phones , status bar contains notifications and system icons. As you can see in above image that area is status bar.
Here we will change background color through xml so it will be work with both java and kotlin. You can change status bar color by many ways but here we are using very simple way to do this. So please follow below steps:-

Please open your project folder and navigate to app/src/main/res/values/styles.xml or just search styles.xml file and then add below line in it

<item name="android:statusBarColor">#333</item>
Here we are using dark color code #333 but you can use any color code according to you and it will be good if you use color according to your app theme.

So after adding this code your code will be look like this

<resources> <!-- Base application theme. -->&…