Using .htaccess 












Using .htaccess/.htpasswd Password Protection 


php5
php5
Coding Tips 






Uploads and Downloads 

php5
php5
php5
Mail 



php5


Working with Images 


Frequently Requested Website Functionality 
php5
php5

php5 see it on this page
php5








Using PHP 
php5
php5
php5


Website Managment 







php5

php5
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
session_start();
// make the character array
$chars = array();
for ($i = 65; $i <= 90; $i++) $chars[] = chr($i);
if (isset($validate)) {
// this section validates the user input
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";
unset($_SESSION['captcha']);
} else {
// this section generated the captcha image
// generate values
for ($i = 1; $i <= 6; $i++) { $key = rand(0, count($chars)-1); $text[$i] = $chars[$key]; }
$_SESSION['captcha'] = $text[1] . $text[2] . $text[3] . $text[4] . $text[5] . $text[6];
// 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, $text[1], $textColor);
imagestring($im, rand(3,5), 15, 5, $text[2], $textColor);
imagestring($im, rand(3,5), 25, 5, $text[3], $textColor);
imagestring($im, rand(3,5), 36, 5, $text[4], $textColor);
imagestring($im, rand(3,5), 45, 5, $text[5], $textColor);
imagestring($im, rand(3,5), 55, 5, $text[6], $textColor);
imagepng($im);
imagedestroy($im);
}
?>