C5-8.2.1: Always get an error

Permalink Browser Info Environment
Hi,

I'm trying to incorporate your library in my form. I've looked at the core's form block and and exactly the same, copied this into view.php:
$captcha = $app->make('captcha');
            if($recaptcha) { ?>
                <div class="form-group">
                    <?php 
                        $captcha->display();
                        $captcha->showInput();
                    ?>
                </div>
            <?php }

and this into the controller.php:
$captcha = $this->app->make('captcha');
            if ($this->recaptcha) {
                if (!$captcha->check()) {
                    array_push($this->form_errors, $this->error_code);
                }
            }

but it always gives me an error saying the code is entered incorrectly (that's the error string $this->error_code). But the core's form works fine. What can be wrong?

Thank you.

Type: Pre-Sale
Status: In Progress
linuxoid
View Replies:
linuxoid replied on at Permalink Reply
linuxoid
Forgot to mention one thing. My form is submitted through AJAX. What does the captcha actually post if anything? Maybe that's the problem. The core's Securimage captcha posts a code. What should I pass to the controller?
exchangecore replied on at Permalink Reply
exchangecore
It checks for the g-captcha-response param which should be the g-recaptcha-response id's value.

https://github.com/ExchangeCore/Concrete5-reCAPTCHA/blob/master/src/...
linuxoid replied on at Permalink Reply
linuxoid
I'm facing another issue. A single form works fine. But if I have 2 or more forms on a page, only the first form passes the test, all other forms fail. Does this library work with multiple forms on a page?

Thank you.

concrete5 Environment Information

# concrete5 Version
Core Version - 8.2.1
Version Installed - 8.2.1
Database Version - 20170802000000

# concrete5 Packages
Advanced Contact Form (0.9.3), Community Store (1.3.1), ExchangeCore reCAPTCHA (1.1.1)

# concrete5 Overrides
None

# concrete5 Cache Settings
Block Cache - Off
Overrides Cache - Off
Full Page Caching - Off
Full Page Cache Lifetime - Every 6 hours (default setting).

# Server Software
Apache

# Server API
apache2handler

# PHP Version
7.0.7

# PHP Extensions
apache2handler, bz2, Core, ctype, curl, date, dom, fileinfo, filter, gd, gettext, hash, iconv, json, libxml, mbstring, mcrypt, mysqli, mysqlnd, openssl, pcre, PDO, pdo_mysql, pdo_sqlite, Reflection, session, SimpleXML, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, zip, zlib

# PHP Settings
max_execution_time - 30
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 60
max_input_vars - 1000
memory_limit - 128M
post_max_size - 8M
sql.safe_mode - Off
upload_max_filesize - 2M
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
session.cache_limiter - <i>no value</i>
session.gc_maxlifetime - 7200

Browser User-Agent String

Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.