friend
i got a problem with captcha code
i created a captcha.php page contains the code to generate an image with random code
i included the following code where i wanted to show this image with this random code
this is the content of the captcha code page
<?php session_start(); $image = imagecreatetruecolor(100,40); $red = imagecolorallocate($image,255,255,255); $yellow = imagecolorallocate($image,rand(1,255),rand(1,255),rand(1,255)); $lines = imagecolorallocatealpha($image,rand(1,200),rand(1,200),rand(1,200),rand(1,60)); $str =''; $i=0; $str=rand(10000,99999); $_SESSION['code']=$str; imagefill($image,0,0,$red); imagettftext($image,20,0,0,30,$yellow,'STENCIL.ttf',$str); for($i=0; $i<30; $i++){ imageline($image,rand(1,200),rand(1,200),rand(1,200),rand(1,200), $lines); } header('content=type: image/gif'); imagegif($image); imagedestroy($image); ?>and it is working so good when using local host but when using the domain name of my website i don,t see this image with this random code although i can see it very well in the local host
i think the reason is caused by the header function cause when i use it to direct the user to a specific page
when using the function
header(“location: index.php”);
it also used to work well on local host but did not work online and i could avoid it
i tried many times with this code but it did not work
i removed the code to display this image and replaced it to print the session
echo “$_SESSION[‘code’]”; but it used to print the same number every time i refresh the page not a random number every time i refresh it also i gives a random number every time when it is on local host
i need your help with this problem