Last active
November 23, 2015 18:35
-
-
Save isralduke/e02fc44da256ca42030a to your computer and use it in GitHub Desktop.
Spam Reduction in Simple Forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$field1 = $_POST['field1']; | |
$field2 = $_POST['field2']; | |
$field3 = $_POST['field3']; | |
$field4 = $_POST['field4']; | |
$field5 = $_POST['field5']; | |
$formcontent = "FieldOne: $field1 \n FieldTwo: $field2 \n FieldThree: $field3 \n FieldFour $field4 \n FieldFive: $field5"; | |
$recipient = "[email protected]"; | |
$subject = "This is the Subject"; | |
$mailheader = "From: $email \r\n"; | |
mail( $recipient, $subject, $formcontent, $mailheader) or die("Error!"); | |
echo "Thanks."; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this file in intentionally left blank |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready( function() | |
{ | |
// feedback after form submissio | |
function confirm() { | |
$("#form").get(0).reset(); | |
// a <p> tag or something with a thank you message | |
$('.confirmation').slideToggle('fast'); | |
} | |
// runs the check to detect if hidden field has been changed | |
$('#submitter').click(function() | |
{ | |
if ( $('#hiddenField').val() !== "" ) | |
{ | |
$('#form').attr("action","spam.php"); | |
// AJAX Form Submitter can be found at https://github.com/malsup/form | |
$('#form').ajaxForm(function() { | |
confirm(); | |
}); | |
} | |
else { | |
$('#form').attr("action","notSpam.php"); | |
// AJAX Form Submitter can be found at https://github.com/malsup/form | |
$('#form').ajaxForm(function() { | |
confirm(); | |
}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment