captcha error


Posted on 16th Feb 2014 07:03 pm by admin

I have been trying to implement a captcha in php...

here is the code..
Code: (php) [Select]<?php
// Set the content-type
header('Content-type: image/png');

// Create the image
$im = imagecreatetruecolor(400, 30);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'arial.ttf';

// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>

But in the browser, it gives the following error...
QuoteThe image “http://127.0.0.1:9000/img1.php” cannot be displayed, because it contains errors.
Somebody tell me the reason and how to fix this ..

No comments posted yet

Your Answer:

Login to answer
158 Like 26 Dislike
Previous forums Next forums
Other forums

apart from cron
I need to run a php file every one hour. Is there any other solution apart from cron job?

max() problem
I have a while loop to get image names.
Code: $imagequery = mysql_query("SELECT * FROM ad_i

BSP Ext - tableView - Sort - NEWBIE
Hi,
I have been trying to get the sort to work. I have defined the column definitions by fillin

first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see

Php - mysql store data and use it later?
Hi, i' making a login page at the moment, however my username + password is stored many different pl

dynamic table with forms
I have a table that is populated with mysql data and in teh first column there is a raido button tha

Show message after entering data
Hello Colleagues

I would like to display messages after entering the data example: "
dat

Transferring session variables into MySQL
I am trying to transfer $_SESSION variables into MySQL. However there is an error in my MySQL statem

Creating web pages by php
Hello again,
I was just wondering us there a way to use a php script to create a new web page. I

SAP Project Module
I have seen in the SAP Project Module,plan cost and budget are not equal and even difference is sign

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash