Search in This Blog

how to check if visitor is a robot or bot

Problem:

how to check if visitor is a robot or bot?

Solution:

Please use below code

Example:

$user_agent='';
if( !isset( $_SERVER['HTTP_USER_AGENT'])){
echo 'i m a Robot!';
die();
} else {
$user_agent=strtolower($_SERVER['HTTP_USER_AGENT']);
}

$robot='N';
if(strpos($user_agent,'bot')>0 || strpos($user_agent,'Bot')>0) {
    $robot='Y';
}

if($robot!='Y')
echo 'I am not a Robot';
else
echo 'I am a Robot';




Previous
Next Post »