Recaptcha v2 in contact form

Issues related to forms.
Post Reply
User avatar
Dragos
 
 
Posts: 217
Joined: Tue Sep 04, 2018 7:08 am

Recaptcha v2 in contact form

Post by Dragos »

I tried to protect myself from spam on the mail server (I use hmailserver and wampserver) using recaptcha v2 checkbox.
Everything goes normally but after sending the message I get a white screen with the error ,,Failed to update table!
Data too long for column 'GRECAPTCHARESPONSE' at row 1" instead of sending me to the web page with the message_ok.
I tried to delete the table from the database and publish the site again, but nothing happened. I guess it's a mistake to create the table in the database when publishing the contact.php page.
User avatar
Pablo
 
Posts: 21720
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Recaptcha v2 in contact form

Post by Pablo »

I think you will have to update the database so it accepts more data.

Note that this is a free extension and it's provided as an extra service "AS IS". There is no support on free extensions.
User avatar
Dragos
 
 
Posts: 217
Joined: Tue Sep 04, 2018 7:08 am

Re: Recaptcha v2 in contact form

Post by Dragos »

SOLVED !!!!
We have edited the database created for contact form in the sense that we have modified the first column called "TIP" of the GRECAPTCHARESPONSE string from varchar 255 in LONG TEXT and so the error was eliminated.
User avatar
Dragos
 
 
Posts: 217
Joined: Tue Sep 04, 2018 7:08 am

Re: Recaptcha v2 in contact form

Post by Dragos »

Maybe the problem is here in contact form:
"$db = mysqli_connect($mysql_server, $mysql_username, $mysql_password) or die('Failed to connect to database server!<br>'.mysqli_error($db));
mysqli_query($db, "CREATE DATABASE IF NOT EXISTS $mysql_database");
mysqli_select_db($db, $mysql_database) or die('Failed to select database<br>'.mysqli_error($db));
mysqli_query($db, "CREATE TABLE IF NOT EXISTS $mysql_table (ID int(9) NOT NULL auto_increment, `DATESTAMP` DATE, `TIME` VARCHAR(8), `IP` VARCHAR(15), `BROWSER` TINYTEXT, PRIMARY KEY (id))");
foreach($form_data as $name=>$value)
{
mysqli_query($db ,"ALTER TABLE $mysql_table ADD $name VARCHAR(255)");
}
mysqli_query($db, "INSERT INTO $mysql_table (`DATESTAMP`, `TIME`, `IP`, `BROWSER`)
VALUES ('".date("Y-m-d")."',
'".date("G:i:s")."',
'".$_SERVER['REMOTE_ADDR']."',
'".$_SERVER['HTTP_USER_AGENT']."')")or die('Failed to insert data into table!<br>'.mysqli_error($db));
$id = mysqli_insert_id($db);
foreach($form_data as $name=>$value)
{
mysqli_query($db, "UPDATE $mysql_table SET $name='".mysqli_real_escape_string($db, $value)."' WHERE ID=$id") or die('Failed to update table!<br>'.mysqli_error($db));
}"
and most add option for use recaptcha extension and chance for "GRECAPTCHARESPONSE" to add LONG TEXT instead of VARCHAR(255)
Post Reply