$sth = $dbh->prepare("SELECT COUNT(*) FROM users WHERE host=? AND date>DATE_SUB(NOW(), INTERVAL 5 MINUTE)"); $sth->execute($host); $row = $sth->fetchrow_arrayref or die "some kinda error"; if ($row->[0]) { # there's already a user in the database which was # registered from this IP, less than five minutes ago. # fail in some way. }