zodehala
12-09-2007, 05:44 PM
form.php
<?php
session_start();
echo '
<form id="form" name="form" method="post" action="form.php?do=1">
<label>
<img src="image.php" />
<input type="text" name="textfield" accesskey="1" tabindex="1" />
</label>
<label>
<input type="submit" name="Submit" value="Submit" accesskey="2" tabindex="2" />
</label>
</form>
';
if($_REQUEST["do"]==1)
{
if (empty($_SESSION['rip']) OR $_SESSION['rip'] != $_REQUEST["textfield"])
{
echo 'False';
}else{
echo 'True';
}
}
?>
image.php
<?php
//Start Session
session_start();
$_SESSION["rip"] = rsayi(4);
################### Draw Pic. ##########################################
header("Content-type: image/png");
$image = imagecreatetruecolor(100, 20) or die("GD Library Error");
$fcolor = imagecolorallocate($image, 255, 255, 255);
$bcolor = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 0, 0, 300, 100, $bcolor);
imagettftext($image, 12, 0, 20, 15, $fcolor, "font/arial.ttf",$_SESSION["rip"]);
imagepng($image);
imagedestroy($image);
################ Random Function ##########################
function rsayi($length=4) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPRQSTUVWXYZ0123456789";
$code = "";
while (strlen($code) < $length) {
$code .= $chars[mt_rand(0,strlen($chars))];
}
return $code;
}
?>
whatever i write it says FALSE ( Evenif i write correctly in pic it says FALSE )
where is my error ?
<?php
session_start();
echo '
<form id="form" name="form" method="post" action="form.php?do=1">
<label>
<img src="image.php" />
<input type="text" name="textfield" accesskey="1" tabindex="1" />
</label>
<label>
<input type="submit" name="Submit" value="Submit" accesskey="2" tabindex="2" />
</label>
</form>
';
if($_REQUEST["do"]==1)
{
if (empty($_SESSION['rip']) OR $_SESSION['rip'] != $_REQUEST["textfield"])
{
echo 'False';
}else{
echo 'True';
}
}
?>
image.php
<?php
//Start Session
session_start();
$_SESSION["rip"] = rsayi(4);
################### Draw Pic. ##########################################
header("Content-type: image/png");
$image = imagecreatetruecolor(100, 20) or die("GD Library Error");
$fcolor = imagecolorallocate($image, 255, 255, 255);
$bcolor = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 0, 0, 300, 100, $bcolor);
imagettftext($image, 12, 0, 20, 15, $fcolor, "font/arial.ttf",$_SESSION["rip"]);
imagepng($image);
imagedestroy($image);
################ Random Function ##########################
function rsayi($length=4) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPRQSTUVWXYZ0123456789";
$code = "";
while (strlen($code) < $length) {
$code .= $chars[mt_rand(0,strlen($chars))];
}
return $code;
}
?>
whatever i write it says FALSE ( Evenif i write correctly in pic it says FALSE )
where is my error ?