codeignitor 3 google robot or not code

first go to link register your site it will give you 2 key 

view

<div class="login-form">
<form action="<?php echo base_url(); ?>user/forgetpasswordprocess" method="post">
<div class="form-row">
<div class="form-group">
<label for="">Email Address</label>
<input type="email" class="form-control" placeholder="Enter Email Address" name="email" required>
<?php echo "<span class='text-danger'>".form_error('email')."</span>"; ?>
</div><br>
<div class="form-group registerfom">
     <div class="g-recaptcha" data-sitekey="6Le2q64ZAAAAACCzc-vnHfmrrWO6VSokrFbfaP4j"></div>
     <?php if(!empty($capchtaerror)){ echo "<span class='text-danger'>".$capchtaerror."</span>"; }?>
</div>
<button type="submit" class="btn btn-primary" name="form1">Submit</button>
</div>
</form>
</div>
<script src="http://www.google.com/recaptcha/api.js"></script>

controller

if(isset($_POST['g-recaptcha-response']))
    {
        $secret = '6Le2q64ZAAAAAKSgsvzNMLLTi5g770Umcvd-NUfm';
            $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)
            {
                $this->form_validation->set_rules('email', 'Email','trim|required');
                if ($this->form_validation->run() == FALSE)
                {
        $this->load->view('user/forgetpassword',$data);
                }
                else
                {
                $email = $this->input->post('email');
                $emailresponse = $this->my_model->getData('tbluser',$resultType = 'row_array',$arg=['where'=>['email'=>$email]]);
                if($emailresponse)
                {
                    $response = sendForgetmailfunction($email);
                    if($response)
                    {
                        $this->session->set_flashdata('mailsuccess','A verification link has been sent to your email. Please check your inbox or spam folder.');
                        $this->load->view('user/forgetpassword',$data);
                    }
                    else
                    {
                        $this->session->set_flashdata('mailerror','Something went wrong,Email is not send.');
                        $this->load->view('user/forgetpassword',$data);
                    }
                }
                else
                {
                    $this->session->set_flashdata('emailerror','Your email is not found. Please provide the valid email address.');
                    $this->load->view('user/forgetpassword',$data);
                }
                }
        }
            else
            {   
                $data['capchtaerror'] = "Please verify yourself ! you are not a robot";
                $this->load->view('user/forgetpassword',$data);
            }
    }
    else
    {
            $data['capchtaerror'] = "Please verify yourself ! you are not a robot";
            $this->load->view('user/forgetpassword',$data);
    }

Comments

Popular posts from this blog

Laravel 8 Multi Auth (Authentication) Tutorial

MySQL - Stored Procedures && Functions

crons job