Jump to content

Капча


viiprogrammer

Recommended Posts

Скрипт капчи на php

<?php
    session_start();   
    $string = "";
    for ($i = 0; $i < 5; $i++)
        $string .= chr(rand(97, 122));
    
    $_SESSION['rand_code'] = $string;
    
    $image = imagecreatetruecolor(180, 50);
    $black = imagecolorallocate($image, 0, 0, 0);
    $color = imagecolorallocate($image, 200, 200, 90);
    $white = imagecolorallocate($image, 255, 255, 255);

    imagefilledrectangle($image,0,0,399,99,$white);
    imagettftext ($image, 30, 0, 10, 40, $color, "ajD4KEAD.ttf", $_SESSION['rand_code']);

    header("Content-type: image/png");
        
    imagepng($image);
?>

Вывод самой картинки капчи на сайте

<img src="файл.php" alt="">

Проверка на правильность введения

 


$kapcha = введённая капча;

 if($kapcha != $_SESSION['rand_code']){
код если введено не верно

}else{

код если введено верно
}

ajD4KEAD.rar

Link to comment
  • 5 months later...
  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...