Categorías
- css (2)
- html (1)
- jQuery (10)
- PHP (3)
- Fechas (1)
- Formularios (2)
- Wordpress (21)
- Avisos / Actualizaciones (2)
- Contact Form 7 (2)
- Divi (1)
- hooks (7)
- Plugins (1)
- Registro (2)
- Woocommerce (6)
Christian Cabrero © 2021
Honeypot PHP simple
Categoria:
PHP, FormulariosSnippet:
<?php
//check if form was sent
if($_POST){
$to = 'some@email.com';
$subject = 'Testing HoneyPot';
$header = "From: $name ";
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
//honey pot field
$honeypot = $_POST['firstname'];
//check if the honeypot field is filled out. If not, send a mail.
if( ! empty( $honeypot ) ){
return; //you may add code here to echo an error etc.
}else{
mail( $to, $subject, $message, $header );
}
}
?>
<title>HoneyPot for HTML Form Example</title>
.hide-robot{
display:none;
}
<!-- Create fields for the honeypot -->
<!-- honeypot fields end -->
<br>
<br>
<textarea name="message" id="message"></textarea><br>
Versiones:
Descripción:
Ejemplo de honeypot PHP simple pero efectivo