some1 has a security code script along numbers/letters system ,to
put on register.php (wapdesire/lava) for to
prevent fake
registration and spamming ?
put on register.php (wapdesire/lava) for to
prevent fake
registration and spamming ?
function regSimpleAuth(){ $num1 = rand(1,20); $num2 = rand(1,20); $ans = $num1 + $num2; return array('question'=>'$num1 + $num2','answer'=>'$ans'); } //reg page $auth = regSimpleAuth(); $_SESSION['ans'] = $auth['answer']; echo 'Are u human?<br/>'.$auth['question'].' = '; echo '<input type="text" name="authSum" value="?" size="3" maxlength="3"/><br/>'; //use this in validation if($_POST['authSum']!= $_SESSION['ans']){ echo 'Incorrect validation answer. E.g 8+8=16'; }else{ //continue registration }
function regSimpleAuth(){ $num1 = rand(1,20); $num2 = rand(1,20); $ans = $num1 + $num2; return array('question'=>'$num1 + $num2','answer'=>'$ans'); } //reg page $auth = regSimpleAuth(); $_SESSION['ans'] = $auth['answer']; echo 'Are u human?<br/>'.$auth['question'].' = '; echo '<input type="text" name="authSum" value="?" size="3" maxlength="3"/><br/>'; //use this in validation if($_POST['authSum']!= $_SESSION['ans']){ echo 'Incorrect validation answer. E.g 8+8=16'; }else{ //continue registration }
<?php
$font = 'arial.ttf';
$lineCount = 10;
$fontSize = 10;
$height = 25;
$width = 80;
$ih = imagecreate($width,$height) or die('GD Library must be installed.');
$bgColor = imagecolorallocate($ih,0,0,0);
$lineColor = imagecolorallocate($ih,178,238,238);
$txtColor = imagecolorallocate($ih,255,255,255);
$str = 'abcdefghijklmnopqrstuvwxyz0123456789';
for($x=0;$x<6;$x++){
$pos = rand(0,strlen($str));
$stri .= $str{$pos};
}
$textbox = imagettfbox($fontSize,0,$font,$stri) or die('Try replacing imagettfbox with imagettfbbox function on d left.');
$x = ($width - $textbox[4])/2;
$y = ($height - $textbox[5])/2;
imagettftext($ih,$fontSize,0,$x,$y,$txtColor,$font,$stri);
for($x=0;$x<$lineCount;$x++){
$x1 = rand(0,$width); $x2= rand(0,$width); $y1 = rand(0,$width); $y2 = rand(0,$width);
imageline($ih,$x1,$y1,$x2,$y2,$lineColor);
}
header('Content-type: image/jpeg');
imagejpeg($ih,NULL,75);
imagedestroy($ih);
session_start();
$_SESSION['captchaAuth'] = $stri;
?>
//the form echo '<img src="captchaimage.php" alt="captcha"/><br/>Enter text above:<input type="text" maxlength="6" name="auth"/>'; //the authentication session_start(); if($_POST['auth']!=$_SESSION['captchaAuth']){ echo 'Incorrect code, try again. Note: cAsE SenSITivE VaLUE'; }else{ //continue reg }
function regSimpleAuth(){
$num1 = rand(1,20); $num2 = rand(1,20);
$ans = $num1 + $num2;
$auth['question'] = "$num1 + $num2";
$auth['answer'] = $num1 + $num2;
return $auth;
}
$auth = regSimpleAuth();
$_SESSION['ans'] = $auth['answer'];
echo "Are u human?<br/>".$auth['question']." = ";
echo "<input type=\"text\" name=\"authSum\" value=\"?\" size=\"3\" maxlength=\"3\"/><br/>";
Comment