jeudi 24 décembre 2015

Custom Color for Captcha

Well , first of all i need to tell you i'm noob with this . I found a php file that generate captcha . It worked but the background was always orange and the text was black . Example Captcha : "3ab6de" . All I want to do is change the background color to another color and to have the text with different colors ( 3ab in red , 6de in blue) . I tried but fail please help me guys ! This is the code:

    <?php
    session_start();
    $random_alpha = md5(rand());
    $captcha_code = substr($random_alpha, 0, 6);
    $_SESSION["captcha_code"] = $captcha_code;
    $target_layer = imagecreatetruecolor(70,30);
    $captcha_background = imagecolorallocate($target_layer, 255, 160, 119);
    imagefill($target_layer,0,0,$captcha_background);
    $captcha_text_color = imagecolorallocate($target_layer, 0, 0, 0);
    imagestring($target_layer, 5, 5, 5, $captcha_code, $captcha_text_color);
    header("Content-type: image/jpeg");
    imagejpeg($target_layer);
    ?>

Thanks !




Aucun commentaire:

Enregistrer un commentaire