num parameters passed via session
Posted: Sun Feb 21, 2010 1:04 pm
Hi,
I passed rnd int parameter via session and later wanted to generate picture (circles) - amount based on that session parameter. Did not worked. PLS help. Thanks.
Session:
session_register("sc");
session_register("se");
if (empty($_SESSION["sc"])) {
$_SESSION['sc']= rand(1,5);
$_SESSION['se']= rand(1,5);
}
PICTURE:
$size = 300;
$image=imagecreatetruecolor($xscale,$yscale);
$back = imagecolorallocate($image, 255, 255, 255);
$border = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 0, 0, $xscale - 1, $yscale - 1, $back);
imagerectangle($image, 0, 0, $xscale - 1, $yscale - 1, $border);
$xc=$_SESSION['sc'];
for ( $counter = 1; $counter<=$xc; $counter += 1) {
$xp=rand($mincirc, $xscale-$mincirc);
$yp=rand($mincirc, $yscale-$mincirc);
$xs=rand($mincirc, $maxcirc);
$v11=rand(0, 255);
$v12=rand(0, 255);
$v13=rand(0, 255);
$yel = imagecolorallocatealpha($image, $v11, $v12, $v13, 75);
imagefilledellipse($image, $xp, $yp, $xs, $xs, $yel);
}
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
return $image;
I passed rnd int parameter via session and later wanted to generate picture (circles) - amount based on that session parameter. Did not worked. PLS help. Thanks.
Session:
session_register("sc");
session_register("se");
if (empty($_SESSION["sc"])) {
$_SESSION['sc']= rand(1,5);
$_SESSION['se']= rand(1,5);
}
PICTURE:
$size = 300;
$image=imagecreatetruecolor($xscale,$yscale);
$back = imagecolorallocate($image, 255, 255, 255);
$border = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 0, 0, $xscale - 1, $yscale - 1, $back);
imagerectangle($image, 0, 0, $xscale - 1, $yscale - 1, $border);
$xc=$_SESSION['sc'];
for ( $counter = 1; $counter<=$xc; $counter += 1) {
$xp=rand($mincirc, $xscale-$mincirc);
$yp=rand($mincirc, $yscale-$mincirc);
$xs=rand($mincirc, $maxcirc);
$v11=rand(0, 255);
$v12=rand(0, 255);
$v13=rand(0, 255);
$yel = imagecolorallocatealpha($image, $v11, $v12, $v13, 75);
imagefilledellipse($image, $xp, $yp, $xs, $xs, $yel);
}
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
return $image;