Forums

Get Browser User Agent?

millermulti 02 Aug, 2017
Hello, I am having issues with search engine bots submitting blank forms, bypassing the required fields. I have read the post in regards to this issue although due to the fact that I have multiple forms on a page, I have run into difficulty implementing the accepted solutions. My thought is to use something similar to a suggestion I read which blocks a submission by IP address. As the search engines use a wide variety of IP addresses I am hoping there is a way I can block based on the User Agent (i.e. bingbot) instead of by IP. Does anyone know if there is a way to check this variable after the submission has occurred? It could be a hidden field which collects the information and passes it on or in could be in the PHP validation code (not sure if this second option will work after the form has been submitted). I would appreciate any recommendations.
millermulti 13 Sep, 2017
Answer
1 Likes
In case anyone else is looking for a similar solution, I am testing the following to stop Bing Bot from submitting blank forms, bypassing the built in form field javascript validation. On my form, under Events, I added "Custom Server Side Validation" as the first "On Submit" event. I then added the following PHP under "Configuration":
<?php
if(strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "bingbot"))
{
    $form->validation_errors['data'] = "Form submitted by BingBot. Failed.";
    return false;
}
?>

and an "Event Loop" in the OnFail field.

In testing I was able to successfully stop the BingBot user agent from submitting the form.
Max_admin 15 Sep, 2017
Hi millermulti,

Good solution, but your form should have some kind of server validtaion or honeypot/captcha to stop all bots anyway.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
millermulti 15 Sep, 2017
Hi Max,

Thanks for the feedback. I do block a number of bots at the server level but have to tread lightly with bots like Google and Bing. Even though these major bots may act poorly if I were to be too aggressive with my blocking I would hear about it from my clients' SEO experts. I have almost 40 forms on the site in question and needed something fairly generic I can apply to all of them. I also ran into an issue with CAPTCHA in that I may have 3 or more forms on a page and CAPTCHA does not do well with multi form pages. This script has been working very well. Zero blank submissions since it was implemented.
Max_admin 20 Sep, 2017
Hi millermulti,

Great, glad to know it works fine!

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.