Jump to content

Detect bot or human


sx

Recommended Posts

Take a look at $_SERVER['HTTP_USER_AGENT']. Most bots will say they are a bot in the value. Here's the "if" statement I use to determine if the visitor is not a human.

<?php
if (preg_match('/slurp|inktomisearch|[Gg]rub|[bb]ot|archiver|[ss]qworm/', $_SERVER['HTTP_USER_AGENT']))
     echo "Is not a human";
?>

 

It's not perfect, but it comes close. You probably want to save this string or email it back to yourself when your site is visited, so you can capture any that are slipping through.

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/43853-detect-bot-or-human/#findComment-213237
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.