I was trying to find a *SIMPLE* way of preventing spam-bots from spamming through my form, I came up with this:
This was adapted from some simple code I found on About.com or something, I've been using it forever... Anyways is it safe or no? I tested and it works fine.Code:<?php if(($_POST['answer'])=="blue") { $to = "theemail"; $subject = $_POST['subject']; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message"; echo "Data has been submitted to $to!"; mail($to, $subject, $body); } else { echo "Error, please try again!"; } ?>



Reply With Quote



Bookmarks