Jump to content

[SOLVED] Captcha Help


jaikob

Recommended Posts

I have this code:

 

<img src="<?php 
$captcha = imagecreatefrompng("captcha.png");
$black = imagecolorallocate($captcha, 0, 0, 0);
$line = imagecolorallocate($captcha,233,239,239);
imageline($captcha,0,0,39,29,$line);
imageline($captcha,40,0,64,29,$line);
imagestring($captcha, 5, 20, 10, $string, $black);
header("Content-type: image/png");
imagepng($captcha); ?>" />

 

 

but all i get is a bunch of giberish like this: �8�OLW�C�A���C� �x���&���&fs6U��%R�I� V�P0Q�Y��i�t�S#��a�n%�&x�(���kv���ۘ� 7

 

how do i fix this.

 

ps, I cannot include this on an include or seperate php file, it has to be in the same file, so i can work with vars set in a previous code on the page.

Link to comment
https://forums.phpfreaks.com/topic/84938-solved-captcha-help/
Share on other sites

You have to link to it. Thats the way it works. If you need to use other variables, either pass them in the URL, or set a session. You should have one php file, lets say captcha.php with your image generation code, and then you should use:

 

<img src="captcha.php?foo=bar" />

Link to comment
https://forums.phpfreaks.com/topic/84938-solved-captcha-help/#findComment-433084
Share on other sites

Archived

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

×
×
  • Create New...

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.