Pages

Wednesday, January 6, 2016

How to block or prevent spam registrations/spam bots on phpmotion web site?


I have done lots of research and tried many possible ways. Finally I found a solution like to use google recaptcha on the website. To do this we need to follow below steps.

1. Register in Google for captcha using the link https://www.google.com/recaptcha/admin#list.
2. After register you will get site key and secrete key.

3. Now open a inner_signup_form.html  page in corresponding theme folder in phpmotion.
4. Delete the captcha code which is by default including javascript code and html code related to captcha. And use the site-key in replace code as "<div class="g-recaptcha" data-sitekey="site-key"></div>"
5.  Save it.
6. Now open the joinup.php code follow below steps...
    a. copy the below code after "if ($procede == true) {"
        if(isset($_POST['g-recaptcha-response'])){
          $captcha=$_POST['g-recaptcha-response'];
        }
    b. Replace below line
        if ( strtolower($_POST['captext']) != strtolower($_SESSION['security_code']) ) {
        with
         if(!$captcha){
        and add exit before "}" closing.
    c. Replace "else" condition for "if ( strtolower($_POST['captext']) != strtolower($_SESSION['security_code']) ) {" which is now "if(!$captcha){"  with below code
        $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=secrete-key&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
        if($response.success==false)
        {
          echo '<h2>You are spammer ! Get the @$%K out</h2>';
        }else
        {
     d. Save it.

Now you won't get spam registration....
Please check below code images for your reference...





No comments:

Post a Comment