0

I want to create form with priority values, first check vlaue of recaptcha if is correct (not spammer) then do process for example:

   if(isset($_POST['g-recaptcha-response']))
{
      $captcha=$_POST['g-recaptcha-response'];

}
    if(!$captcha)
        {
        echo "enter captcha";

    }

    $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=*******&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);

        if($response.success==TRUE){

            $name = $_POST['name'];

            if($name == "hello"){
                echo 'correct';
            }

        else {
                echo 'incorrect';
            }
        }


    if($response.success==false)
    {
        die("spammer!");

    }

and HTML code like:

      <form id="form" method="POST" action="">

                     <input id="name" name="name" type="text"/>

                 <div class="g-recaptcha-response" data-sitekey="******"></div>

                 <input id="button" type="submit" value="send" />
</form>  

                  <div id="formresult"></div>

<div id="formresult"></div> is for ajax answer

I wrote some script code but not worked and I prefer ask without paste that code in here. how could I do that?

mahdi
  • 31
  • 6

0 Answers0