... |
|
Beste SiMa's ...
Ik hoop dat iemand mij kan helpen en het gaat waarschijnlijk vrij simpel zijn maar ik kom er niet uit of ik overzie iets...
security_code.php ->
<?php
session_start();
class CaptchaSecurityImages {
var $font = 'monofont.ttf';
function generateCode($characters) {
$possible = '23456789bcdfghjkmnpqrstvwxyz';
$code = '';
$i = 0;
while ($i < $characters) {
$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
$i++;
}
return $code;
}
function CaptchaSecurityImages($width='120',$height='40',$characters='6') {
$code = $this->generateCode($characters);
$font_size = $height * 0.75;
$image = @imagecreate($width, $height) or die('Kan nieuwe afbeelding niet plaatsen.');
$background_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 20, 40, 100);
$noise_color = imagecolorallocate($image, 100, 120, 180);
for( $i=0; $i<($width*$height)/3; $i++ ) {
imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
}
for( $i=0; $i<($width*$height)/150; $i++ ) {
imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
}
$textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Fout in imagettfbbox functie');
$x = ($width - $textbox[4])/2;
$y = ($height - $textbox[5])/2;
imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Fout in imagettftext functie');
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
$_SESSION['security_code'] = $code;
}
}
$width = isset($_GET['width']) ? $_GET['width'] : '120';
$height = isset($_GET['height']) ? $_GET['height'] : '40';
$characters = isset($_GET['characters']) && $_GET['characters'] > 1 ? $_GET['characters'] : '6';
$captcha = new CaptchaSecurityImages($width,$height,$characters);
?>
<?php class CaptchaSecurityImages { var $font = 'monofont.ttf'; function generateCode($characters) { $possible = '23456789bcdfghjkmnpqrstvwxyz'; $code = ''; $i = 0; while ($i < $characters) { $i++; } return $code; } function CaptchaSecurityImages($width='120',$height='40',$characters='6') { $code = $this->generateCode($characters); $font_size = $height * 0.75; $image = @imagecreate ($width, $height) or die('Kan nieuwe afbeelding niet plaatsen.'); $background_color = imagecolorallocate($image, 255, 255, 255); $text_color = imagecolorallocate($image, 20, 40, 100); $noise_color = imagecolorallocate($image, 100, 120, 180); for( $i=0; $i<($width*$height)/3; $i++ ) { imagefilledellipse ($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color); } for( $i=0; $i<($width*$height)/150; $i++ ) { } $textbox = imagettfbbox ($font_size, 0, $this->font, $code) or die('Fout in imagettfbbox functie'); $x = ($width - $textbox[4])/2; $y = ($height - $textbox[5])/2; imagettftext ($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Fout in imagettftext functie'); header('Content-Type: image/jpeg'); imagejpeg($image); imagedestroy($image); $_SESSION['security_code'] = $code; } } $width = isset($_GET['width']) ? $_GET['width'] : '120'; $height = isset($_GET['height']) ? $_GET['height'] : '40'; $characters = isset($_GET['characters']) && $_GET['characters'] > 1 ? $_GET['characters'] : '6'; $captcha = new CaptchaSecurityImages($width,$height,$characters); ?>
en het stukje in het contactformulier voor de code: ->
<td colspan="2">
<img src="security_code.php?width=100&height=40&characters=5" /><br />
<label for="security_code">Security Code: </label><input id="security_code" name="security_code" type="text" /></td>
<td colspan="2"> <img src="security_code.php?width=100&height=40&characters=5" /><br /> <label for="security_code">Security Code: </label><input id="security_code" name="security_code" type="text" /></td>
Wat er juist fout gaat?
Wel, als ik het formulier invul en het verzend zonder de verificatie-code in te vullen, word het gewoon verzonden zonder dat er gecontroleerd word of de code is ingevuld en/of die ook correct is...
Kan iemand mij mss ff helpen aub?
Alvast bedankt...
|