PDA

View Full Version : کد captcha



پاتریک
سه شنبه 29 دی 1394, 22:57 عصر
سلام من کتابخانه https://github.com/Gregwar/Captcha رو دانلود کردم ولی نمی دونم کدوم قسمت ها رو به برنامه اضافه کنم . برنامه طراحی صفحه ثبت نام به زبان php و بدون استفاده از framework ها و بدون composer هستش . :گریه:

tamafi6
چهارشنبه 30 دی 1394, 00:15 صبح
کد های مربوط به کلمات واعدادتصادفی باید دربین فرم php قرارداده بشه وتگ رابه فرم php تون اضافه کنیدمانند:


function mathCaptcha($input='', $sum='') {
$length = 4;
if (isset($_POST['calc'])) {
if (is_numeric($input) && strlen($sum) == $length) {$math = substr(md5($input),0,$length) === $sum ? $input : null;}
}
else {
$x = rand(1, 9); $y = rand(1, 9);
$sum = substr(md5($x+$y),0,$length);
$math = '<label for="calc">'.l('math_captcha').':</label>';
$math .= '<p style="width:60%;" dir="ltr">'.$x.' + '.$y.' = </p>';
$math .= '<input type="text" name="calc" id="calc" dir="ltr" />';
$math .= '<p><input type="hidden" name="sum" value="'.$sum.'" /></p>';
}
return $math;
}