Using .htaccess 












Using .htaccess/.htpasswd Password Protection 





Coding Tips 








Uploads and Downloads 



Mail 
see it on this page





Working with Images 


Frequently Requested Website Functionality 
see it on this page

see it on this page
see it on this page
see it on this page











Using PHP 




Website Managment 








Other Tips 









CAPTCHA
A CAPTCHA (an acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart", trademarked by Carnegie Mellon University) is a type of challenge-response test used in computing to determine whether or not the user is human.
<?php
//
// to validate the user entered value the variable $validate must be populated with the user input
// $validate will return with either "valid" or "invalid"
// if $validate is not set then a captcha image is generated
//
// to make the captcha harder for a bot to read, the font is random for each character and there are lines in the image
//
// this section validates the user input
session_start();
if (isset($validate)) {
if (strlen($validate) == 6) {
$validate = strtoupper($validate); // make input upper case for compare
if ($_SESSION['captcha'] == $validate) $validate = "valid"; else $validate = "invalid";
} else $validate = "invalid";
} else {
//
// this section generates the captcha value
$char1 = chr(rand(65,90));
$char2 = chr(rand(65,90));
$char3 = chr(rand(65,90));
$char4 = chr(rand(65,90));
$char5 = chr(rand(65,90));
$char6 = chr(rand(65,90));
$_SESSION['captcha'] = $char1.$char2.$char3.$char4.$char5.$char6;
// create image
$im = @imagecreate(70,25);
$backgroundColor = imagecolorallocate($im,150,150,150);
$textColor = imagecolorallocate($im,0,0,0);
$lineColor = imagecolorallocate($im,100,100,100);
imageline($im,0,0,23,25,$lineColor);
imageline($im,23,0,46,25,$lineColor);
imageline($im,46,0,69,25,$lineColor);
imageline($im,0,25,70,0,$lineColor);
imagestring($im,rand(3,5),5,5,$char1,$textColor);
imagestring($im,rand(3,5),15,5,$char2,$textColor);
imagestring($im,rand(3,5),25,5,$char3,$textColor);
imagestring($im,rand(3,5),36,5,$char4,$textColor);
imagestring($im,rand(3,5),45,5,$char5,$textColor);
imagestring($im,rand(3,5),55,5,$char6,$textColor);
imagepng($im);
imagedestroy($im);
}
?>




