- Код за потвърждение: Избери целия код
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>I'm the Bot Buster</title>
<style type="text/css">
#inputcheck {display: hidden;}
#registerform inputcheck {float:left; margin-right: 3px; background-color: #FFFFFF; border-color: #B4BAC0; color: #333333;}
</style>
</head>
<body>
<form id="registerform" method="post" action="send.php">
<label for="inputcheck">Input Check Bots!<label>
<input type="text" id="inputcheck" value=""> <!-- This is the bot trap. If this field is filled, than it's bot. -->
<button type="submit">Submit</button>
</form>
</body>
</html>
Форма. Вътре имаме един поле - което се казва inputcheck. Това поле е hidden.
С този код проверяме дали полето е попълненто. Ако е попълнено обаче - значи бот се опитва да манипулира формата.
- Код за потвърждение: Избери целия код
<?php
// if the url field is empty
if(isset($_POST['inputcheck']) && $_POST['inputcheck'] == ''){
// then send the form to your email
mail( '[email protected]', 'Contact Form', print_r($_POST,true) );
}
// otherwise, let the spammer think that they got their message through
?>
С сигурност не съм се справил перфектно, но който разбира и иска да се включи е добре дошъл.