*UPDATE
Aliens Abducted Me - Report an Abduction
now with reCAPTCHA
Form:
Script:
reCAPTCHA: Stop Spam, Read Books
Aliens Abducted Me - Report an Abduction
now with reCAPTCHA
Form:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[URL]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/URL]">
<html xmlns="[URL="http://www.w3.org/1999/xhtml"]XHTML namespace[/URL]" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Aliens Abducted Me - Report an Abduction</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<script>
var RecaptchaOptions = {
theme : 'blackglass',
tabindex : 2
};
</script>
<h2>Aliens Abducted Me - Report an Abduction</h2>
<p>Share your story of alien abduction:</p>
<form method="post" action="report.php">
<label for="firstname">First name:</label>
<input type="text" id="firstname" name="firstname" /><br />
<label for="lastname">Last name:</label>
<input type="text" id="lastname" name="lastname" /><br />
<label for="email">What is your email address?</label>
<input type="text" id="email" name="email" /><br />
<label for="whenithappened">When did it happen?</label>
<input type="text" id="whenithappened" name="whenithappened" /><br />
<label for="howlong">How long were you gone?</label>
<input type="text" id="howlong" name="howlong" /><br />
<label for="howmany">How many did you see?</label>
<input type="text" id="howmany" name="howmany" /><br />
<label for="aliendescription">Describe them:</label>
<input type="text" id="aliendescription" name="aliendescription" size="32" /><br />
<label for="whattheydid">What did they do to you?</label>
<input type="text" id="whattheydid" name="whattheydid" size="32" /><br />
<label for="fangspotted">Have you seen my dog Fang?</label>
Yes <input id="fangspotted" name="fangspotted" type="radio" value="yes" />
No <input id="fangspotted" name="fangspotted" type="radio" value="no" /><br />
<img src="fang.jpg" width="100" height="175"
alt="My abducted dog Fang." /><br />
<label for="other">Anything else you want to add?</label>
<textarea id="other" name="other"></textarea><br /><br />
<label>Enter the text to continue.</label>
<!--reCAPTCHA-->
<?php
require_once('recaptchalib.php');
$publickey = "6Le1KLoSAAAAAFZOSVgSnnjq24s5wmIKA5NieuDq";
echo recaptcha_get_html($publickey);
?>
<!--end reCAPTCHA-->
<br />
<input type="submit" value="Report Abduction" name="submit" class="submit" />
</form>
<br /> <br /> <br /> <br /> <!--Bit of whitespace-->
</body>
</html>
Script:
Code:
<html>
<head>
<title>Aliens Abducted Me - Report an Abduction</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h2>Aliens Abducted Me - Report an Abduction</h2>
<?php
//reCAPTCHA
require_once('recaptchalib.php');
$privatekey = "6Le1KLoSAAAAAAbgabcGj6m8cL2R-6D9AcaPImPx";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Get the fuck off!." . //lol
"(reCAPTCHA said: " . $resp->error . ")");
}
// script varaibles
$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
$email = $_POST['email'];
$when_it_happened = $_POST['whenithappened'];
$how_long = $_POST['howlong'];
$how_many = $_POST['howmany'];
$alien_description = $_POST['aliendescription'];
$what_they_did = $_POST['whattheydid'];
$fang_spotted = $_POST['fangspotted'];
$other = $_POST['other'];
//email variables
$to = 'leedswebsolutions@googlemail.com'; //dont spam me
$subject = 'Aliens Abducted Me - Abduction Report';
//email message string variable
$msg = "$first_name $last_name was abducted on $when_it_happened and was gone for $how_long\n" .
"Number of aliens: $how_many\n" .
"Describe them: $alien_description\n" .
"What they did: $what_they_did\n" .
"Was Fang there? $fang_spotted\n" .
"Other comments: $other\n";
//HTML response
echo 'Thanks for submitting the form.<br />';
echo $first_name . ' ' . $last_name .', you were abducted ' . $when_it_happened . ' and gone for ' . $how_long . '.<br />';
echo 'Number of aliens: ' . $how_many . '.<br />';
echo 'Describe them: ' . $alien_description . '.<br />';
echo 'What they did: ' . $what_they_did . '.<br />';
echo 'Was Fang there? ' . $fang_spotted . '.<br />';
echo 'Other comments: ' . $other . '.<br />';
echo 'Your email address is ' . $email;
//send email
mail($to, $subject, $msg, 'From:' . $email);
?>
</body>
</html>
reCAPTCHA: Stop Spam, Read Books