Help needed with CakePHP and hCaptcha server verification

Hello Everyone.

I am new to PHP and I am trying to implement hCaptcha on a series of sites made in CakePHP by using the guide below:

I have the hCaptcha being correctly displayed on the login and signup and ad post pages of my site from the client side. You can click it and solve it.

My issue is with server side verification part and also that the hCaptcha field is not mandatory (how would I do that?).

I think that the server side verification code goes in the UserController.php file of my site. This file contains functions relating to login and registering.

For example the login function looks like this currently:

function login() {
    	if (!empty($this->rememberUser)) {
        if ($this->data) {
			$this->data = Sanitize::clean($this->data,  array('encode' => false, 'underscore' => false));
            $objUser = $this->User->find('first', array("conditions" => "(User.c_email='".$this->data['User']['c_email']."' or User.c_username='".$this->data['User']['c_email']."')
						AND User.c_password='".$this->data['User']['c_password']."'"));
			if ($objUser) {
                if ($this->data['User']['c_remember'] != "0") {
                    $this->Cookie->write('User', $objUser, false, '1 year');
                } else {
                    $this->Session->write('User', $objUser);
            } else {

How do I edit this segment to implement hCaptcha’s server side verification, or am I looking in the wrong place?

Any help is much appreciated.

Sponsor our Newsletter | Privacy Policy | Terms of Service