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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.