Categorías

Honeypot PHP simple

Categoria:

PHP, Formularios

Snippet:

<?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



Code Snippets