Jump to content


This topic is now archived and is closed to further replies.


image verification

Recommended Posts

hello, I was having trouble with image verifications. I'm pretty sure my code is correct but JUST in case here it is [code]<tr>

            <td width="50%"><p align="right">Username: </p></td>

            <td><input name="username" class="FacetInput" id="username" maxlength="20"></td>


          <tr align="right">

            <td>Password: </td>

            <td align="left"><input name="password" type="password" class="FacetInput" id="password" maxlength="25"></td>




            <td><img src="ver.php" alt="security image" border="0"/></td>



            <td><p align="right">Verification: </p></td>

            <td><input name="answer" class="FacetInput" id="answer" maxlength="8"></td>

          </tr>[/code] that's for the page that needs verified now here's ver.php [code]<?php
function randstr($length, $hash = "abcdefghijklmnopqrstuvwxyz0123456789") {
    $strlength = strlen($hash);
    $string = "";
    for($i = 0; $i < $length; $i++) {
                $random = rand(0, $strlength) - 1;
            $string .= substr($hash, $random, 1);
    return $string;
$string = randstr(5);
setcookie("hash", md5($string), time()+3600);
$width = 100;
$height = 35;
$imgTXT = $string;
$hTXT = rand(25,25);
$wTXT = rand(10,30);
$angleTXT = rand(-25, 25);
$sizeTXT = 13;
$imgCreate = ImageCreate($width, $height);
$imgBg = ImageColorAllocate($imgCreate, 0, 0, 0);
$imgFg = ImageColorAllocate($imgCreate, 255, 255, 255);
ImageFill($imgCreate, 1, 1, $imgBg);
Imagettftext($imgCreate,$sizeTXT,$angleTXT,$wTXT,$hTXT,$imgFg,'font/tahoma.ttf',$string) or die ("Please refresh");
header('Content-type: image/png');
What it's doing is:
Its just showing up as no image...it has an image holder(in opera) saying 'security image" or what ever...but no picture...any suggestions?

Share this post

Link to post
Share on other sites
It seems fine to me, except for most of last character sometimes being lost off the edge on downward sloping images.

Is ver.php in same folder as the form script?

Share this post

Link to post
Share on other sites
Yes in the same, i did a GD LIbrary Test and it failed i don't have it installed...how would i got about instaling it?

Share this post

Link to post
Share on other sites
In php.ini file check the path to your extensions folder

[code]extension_dir = path/to/extensions[/code]

and make sure "php_gd2.dll" ( or .so if linux) is in the folder.

Also in php.ini find the line

and remove the ";" from beginning

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.