Search
Left Quote    Treat your password like your toothbrush. Don't let anybody else use it, and get a new one every six months.
- Clifford Stoll    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: CAPTCHA
  This user is offline  gravy
  Subject: "CAPTCHA" Posted: @ 8:46 pm on Jun 10 2007   

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

I followed the code sample to the tee, but for some reason can not get it to display the images needed for the actual verifying. Any thoughts on that....


Photo Hosting Scripts? It's what I do....
    Viewed: 7,718 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: CAPTCHA" Posted: @ 11:03 pm on Jun 10 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Do you have the GD Library? I think you can do a php_info(); and it will tell you or not... Do you see any image? Did you verify the paths to the images? Also if your server is linux, then the path names will be CaSe SeNsItIvE. Meaning, /images/ is different than /Images/ so be careful!




-bs0d | AllSyntax.com

    Viewed: 7,711 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: CAPTCHA" Posted: @ 11:26 pm on Jun 10 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

  bs0d said...

< i> Do you have the GD Library? I think you can do a php_info(); and it will tell you or not... Do you see any image? Did you verify the paths to the images? Also if your server is linux, then the path names will be CaSe SeNsItIvE. Meaning, /images/ is different than /Images/ so be careful!

Yes I do have the GD Library!
Also verified the paths, they are correct.... HEre is my captcha.php code:

Code:

session_start( );
$_SESSION['cod e'] = "";

//generate code
$string = substr( crypt( rand( ) ), -5 );

//unwanted characters
$junk = array('.' , ',' , '/' , '' , '`' , ';' , '[' , ']' , '-', '_', '*', '&', '^', '%', '$', '#', '@', '!', '~', '+', '(', ')', '|', '{', '}', '<', '>', '?', ':', '"', '=');

//strip unwanted
$string = str_replace( $junk, '', $string );

//image background
$im = imagecreatefrom png( "http://w ww.imagerabbit. com/gfx/captcha .png" );
$orange = imagecoloralloc ate( $im, rand(1,100), rand(1,100), rand(1,100) );

$half = imagesx( $im ) / 2;
$start = rand( 10, $half / 1.5 );
$y = imagesy( $im ) / 2;
$pos = $start;

for ( $i = 0; $i < strlen( $string ); $i++ ) {
imagestring( $im, 100, $pos, $y, $string[$i], $orange );

$pos += rand(11,15);
$y += 5-rand(0,10);
}
//image cover
$cov = imagecreatefrom png( "http://w ww.imagerabbit. com/gfx/captcha _c.png" );
imagecopyresamp led( $im, $cov, 0, 0, 0, 0, 300, 100, 300, 100 );

header('Conten t-type: image/png');
imagepng($im);
imagedestroy($i m);

$_SESSION['cod e'] = $string;
session_write_c lose();



The ofrm part was easy, i guess the only thing that would screw it would be the:

Code:

<img src="http ://www.imagrabb it.com/captcha. php">< br />



any more thoughts?




Photo Hosting Scripts? It's what I do....

    Viewed: 7,708 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: CAPTCHA" Posted: @ 12:32 am on Jun 11 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Are you double sure on the paths to those images? I entered in the URL in my browser and I get a 404 - Not Found.

Also no errors from PHP? It just don't display the image?




-bs0d | AllSyntax.com

    Viewed: 7,705 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: CAPTCHA" Posted: @ 1:43 am on Jun 11 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

  bs0d said...

< i> Are you double sure on the paths to those images? I entered in the URL in my browser and I get a 404 - Not Found.

Also no errors from PHP? It just don't display the image?

LOL!!!
Yeah the filenames were wrong for the images!!
But now I have another problem, there are no letters displayed over the image?




Photo Hosting Scripts? It's what I do....

    Viewed: 7,702 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: CAPTCHA" Posted: @ 1:47 am on Jun 11 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

  gravy said...

< i>   bs0d said... Are you double sure on the paths to those images? I entered in the URL in my browser and I get a 404 - Not Found.

Also no errors from PHP? It just don't display the image?

LOL!!!
Yeah the filenames were wrong for the images!!
But now I have another problem, there are no letters displayed over the image?

NEVERMIND, I forgot to make the captcha_c.png transparent, but I did now so I can see those numbers and letters that were covered up by the image before.....Smar t huh...




Photo Hosting Scripts? It's what I do....

    Viewed: 7,701 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: CAPTCHA" Posted: @ 2:20 am on Jun 11 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Awesome, glad you got it to work! Hopefully it will prevent spam on your site




-bs0d | AllSyntax.com

    Viewed: 7,698 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank