[code]
<?php
session_start ( );
srand ( microtime ( ) * 100000000 );
function gen_string ( $num_chars = 6 )
{
	$chars = 'a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0';
	$chars = explode ( ' ', $chars );
	for ( $i = 0; $i < $num_chars; $i++ )
	{
		if ( strlen ( $return ) < $num_chars )
		{
			$return .= $chars[rand ( 0, ( count ( $chars ) - 1 ) )];
		}
	}
	return $return;
}
if ( $_POST )
{
	if ( md5 ( base64_encode ( $_POST['code'] ) ) == $_POST['the_code'] )
	{
		die ( '<font color="#008000">Correcte Code!</font>' );
	}
	else
	{
		die ( '<font color="#800000">Foute Code!</font>' );
	}
}
if ( isset ( $_GET['image'] ) )
{
	// Alle instellingen:D
	session_start ( );
	$code = ( $_SESSION['string'] ) ? base64_decode ( $_SESSION['string'] ) : 'ReLoAd';
	$lines = 25;
	$dots = 100;
	$width = strlen ( $code ) * 20;
	$height = 30;
	$im = imagecreate ( $width, $height );
	// kleuren
	$bg = imagecolorallocate ( $im, 0xff, 0xff, 0xff );
	$text_color = imagecolorallocate ( $im, 0x00, 0x00, 0x00 );
	$line_color = imagecolorallocate ( $im, 0x00, 0x80, 0x00 );
	$dot_color = imagecolorallocate ( $im, 0x80, 0x00, 0x00 );
	imagecolortransparent ( $im );
	// lijnen
	for ( $line = 0; $line < $lines; $line++ )
	{
		imageline ( $im, rand ( 0, $width ), rand ( 0, $height ), rand ( 0, $width ), rand ( 0, $height ), $line_color );
	}

	// stippen
	for ( $dot = 0; $dot < $dots; $dot++ )
	{
		imagesetpixel ( $im, rand ( 0, $width ), rand ( 0, $height ), $dot_color );
	}

	// en nu het ECHTE werk:D
	// de tekst
	$chars = preg_split ( '//', $code );
	$x = -12;

	for ( $i = 0; $i < count ( $chars ); $i++ )
	{
		imagechar ( $im, rand ( 5, 5 ), $x, rand ( 0, $height - 15 ), $chars[$i], $text_color);
		$x = $x + 20;
	}

	if ( function_exists ( 'imagegif' ) )
	{
		header ( 'Content-Type: image/gif' );
		imagegif ( $im );
	}
	elseif ( function_exists ( 'imagejpeg' ) )
	{
		header ( 'Content-Type: image/jpeg' );
		imagejpeg ( $im );
	}
	imagedestroy ( $im );
}
else
{
	$characters = ( $_GET['chars'] ) ? $_GET['chars'] : 6;
	$_SESSION['string'] = base64_encode ( gen_string ( $characters ) );
?>
<html dir="ltr">
<head>
<title>Verificatie Test</title>
</head>
<body bgcolor="grey">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="code" maxlength="6" size="6">&nbsp;&nbsp;&nbsp;<img src="<?php echo $_SERVER['PHP_SELF']; ?>?image" height="30px" width="<?php echo ( 20 * $characters ); ?>px" alt="Code">
<br /><input type="hidden" name="the_code" value="<?php echo md5 ( $_SESSION['string'] ); ?>"><input type="submit">
</form>
</body>
</html>
<?php
}
?>
[/code]