Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd additional noise to Captcha image?
    text
    copied!<p>I have this simple captcha script from online. I like it, and I edited it to suit my site, but was wondering if someone could edit it to add some random lines on the captcha itself as it is somewhat too simple.</p> <p>I did find tutorials on how to do it but it was not working for me.</p> <p>Here is the simple captcha script; I would love to modify it to have some random lines appear on the captcha:</p> <pre><code> $width = 150; $height = 24; $length = 5; $font = 'caviardreams.ttf'; $font_size = 14; $bg_color = array(245, 245, 245); $chars = 'ABCDEFGHKMNPQRSTUVWXYZ23456789'; session_start(); //putenv('GDFONTPATH=' . realpath('.')); $img = imagecreatetruecolor($width, $height); $bkgr = imagecolorallocate($img, $bg_color[0], $bg_color[1], $bg_color[2]); imagefilledrectangle($img, 0, 0, $width, $height, $bkgr); $code = ''; for($i = 0; $i &lt; $length; $i++) { $code .= $chr = $chars[mt_rand(0, strlen($chars)-1)]; $r = rand(0, 192); $g = rand(0, 192); $b = rand(0, 192); $color = imagecolorallocate($img, $r, $g, $b); $rotation = rand(-35, 35); $x = 5+$i*(4/3*$font_size+2); $y = rand(4/3*$font_size, $height-(4/3*$font_size)/2); imagettftext($img, $font_size, $rotation, $x, $y, $color, $font, $chr); } $_SESSION['random_txt'] = md5($code); header("Content-type: image/png"); header("Expires: Mon, 01 Jul 1998 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); imagepng($img); imagedestroy($img); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload