Jump to content

[SOLVED] Issues with Captcha


Eggzorcist

Recommended Posts

I have one major issue with my captcha, It's doing everything I want it to but one thing.

I thinks its alone on the page and makes my register.php a png image and outputting nothing else but itself.

 

heres my code:

<?php
function create_captcha($length){

//Creates md5 hash
$hash = md5(rand(0, 9999));

//creates a code with $length  
$code = substr($hash, 15, $length);

//stores the code into a session
$_SESSION['captcha'] = $code;  

//image size
$width = 150;
$height = 50;

//creates the image
$image = imagecreate($width, $height); 

//creates background and text colours
$background = imagecolorallocate($image, 0, 0, 0);
$text = imagecolorallocate($image, 255, 255, 255);

//creates the image
imagefill($image, 0, 0, $background); 

//Specifies font and text
imagettftext($image, 42, 5, 15, 55, $text, "captcha.ttf", $code);

//Tells the browser what kind of image is being outputted. 
header("Content-Type: image/png"); 

//creates the image
imagepng($image);

//frees up resources
imagedestroy($image); 
}
?>

 

thanks

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.