Code: Select all
<?php
session_start(); //Use the session we made to get the client's input
$user_content=trim($_POST['user_content']);
$captcha_guess=strtolower(trim($_POST['captcha_guess']));
if(isset($_SESSION['encoded_captcha'])) {
if($_SESSION['encoded_captcha'] == md5($captcha_guess)) {
if($user_content != "") {
//It's a human, or a really smart bot
echo("<p style='color:green;'>Congratz! You passed the CAPTCHA test! Your submition has been received. It was: ");
echo($user_content);
} else {
echo("<p style='color:red;'>Your submission is empty. Try again.</p>");
}
} else {
//The bot (either that or he's an idiot) entered the wrong captcha
//Pwn him!!!
echo("<p style='color:red;'>You did not enter the CAPTCHA correctly. Try again.</p>");
}
}
unset($_SESSION]["encoded_captcha"]);
?>