<?php
session_start();
header("Content-type: image/png");

$img_handle = imageCreateFromPNG("bg2.PNG");

$q = rand(1,255);
$w = rand(1,255);
$e = rand(1,255);
$r = rand(1,255);
$t = rand(1,255);
$y = rand(1,255);
$u = rand(1,255);
$i = rand(1,255);
$color[0] = ImageColorAllocate ($img_handle, $q, 0, 100); 
$color[1] = ImageColorAllocate ($img_handle, 200, 0, 0);
$color[2] = ImageColorAllocate ($img_handle, 0, $w, 100);
$color[3] = ImageColorAllocate ($img_handle, 200, 0, 0);
$color[4] = ImageColorAllocate ($img_handle, 0, $e, 100);
$color[5] = ImageColorAllocate ($img_handle, 200, 0, 0);
$color[6] = ImageColorAllocate ($img_handle, 0, $r, $y);
$color[7] = ImageColorAllocate ($img_handle, 0, $t, 100);
$color[8] = ImageColorAllocate ($img_handle, 200, 0, 0);
$color[9] = ImageColorAllocate ($img_handle, $u, $y, 100);
$color[10] = ImageColorAllocate ($img_handle, 200, 0, 0);
$color[11] = ImageColorAllocate ($img_handle, 0, $u, 100);
$color[12] = ImageColorAllocate ($img_handle, 0, $i, 100);
$rkey=trim($_SESSION['rkey']); 
$characters=str_split($rkey); 
$x=30; 
$j=0; 
for($i=0;$i<count($characters);$i++)
{
    ImageString($img_handle, 5, $x, 13, $characters[$i], $color[$j]);
    $x=$x+7;
    $j=$j+1;
    if($j==13) 
        $j=0;
}
ImagePNG($img_handle);
$img_handle = $_SESSION['img'];
ImageDestroy($img_handle);
?>

okay guys above is my code. I would like to know if there is any way to write out the image created into a .png file in my root folder?. The image is generated fine but i cant seem to find a .png file anywhere. Any thoughts?.

Thanks
Danny

hmm i dont understand do u have an example?

btw. is there any way to embed it into an e-mail without having to write out the image?

Thanks
Danny

thanks for that. okay ive replace my code with that line. but now heres the problem. the image file is created. but whenever i refresh the page a new set of numbers combines with the old numbers. i would like my code to maybe create a new image each time.
Is there any way?

Thanks
Danny

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.