Показать сообщение отдельно

  #10  
Старый 25.05.2007, 07:36
Isis
Флудер
Регистрация: 20.11.2006
Сообщений: 3,315
С нами: 10248806

Репутация: 2371


По умолчанию

captcha.php
PHP код:
<?php
session_start
();
session_register('code');
$_SESSION['code'] = rand(1000000,9999999);
for(
$i 0$i 7$i++) {
    
$arr[$i] = substr($_SESSION['code'],$i,1);
}
$im imagecreate(130,40);
imagecolorallocate($im,255,255,255);
$a 0;
for(
$i 0$i 7;$i++)
{
    
$color=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
    
imagestring($im,3,$a+=15,0,$arr[$i],$color);
}
header("Content-type: image/jpeg");
imagejpeg($im,'',100);
?>
form.php
PHP код:
<?php
session_start
();
?>
<img src="captcha.php" />
<form method="post">
Enter code : <input type="text" name="get_code">
<input name="sub" type=submit value="Проверить">
</form>
<?php
if($_POST['sub']) {
    if(
$_POST['get_code'] == $_SESSION['code']) {
        echo 
"Картинка введена верно";
    } else {
        echo 
"Картинка введена неверно";
    }
}
?>
 
Ответить с цитированием