The problem is that once I upload it to a server it stops working. I imagine this has something to do with headers...but I am not sure. In anycase, here's my code:
Display page uses this simple command:
Code: Select all
<img src="http://www.mysite.com/scripts/php_captcha.php">Code: Select all
<?php
session_start();
$RandomStr = md5(microtime());// md5 to generate the random string
$ResultStr = substr($RandomStr,0,5);//trim 5 digit
$NewImage = imagecreatefromjpeg("img.jpg");//image create by existing image and as back ground
$LineColor = imagecolorallocate($NewImage,233,239,239);//line color
$TextColor = imagecolorallocate($NewImage, 255, 255, 255);//text color-white
imageline($NewImage,1,1,40,40,$LineColor);//create line 1 on image
imageline($NewImage,1,100,60,0,$LineColor);//create line 2 on image
imagestring($NewImage, 5, 20, 10, $ResultStr, $TextColor);// Draw a random string horizontally
$_SESSION['key'] = $ResultStr;// carry the data through session
header("Content-type: image/jpeg");// out out the image
imagejpeg($NewImage);//Output image to browser
?>Even the session variable stored to in php_captcha isn't being stored to on the web...leading me to believe that the php_captcha.php program is never run properly.
Any ideas on what could be causing this setup to work on my computer with Apache and yet fail when uploaded to a web server?