Greetings,
i've been working on a random verification image the past days, i am facing a really weird problem, here's my code and i will explain below...
<?php
// register.php
if ( !isset($_POST["submit"]) )
{
include("image.php");
?>
<form method="post" action="register.php">
<input type="text" name="sa">
<input type="submit" name="submit">
</form>
<?php
}
else
{
if ( $_POST["sa"] == $sal )
{
echo "Your Verification Number ". "<b>".$sal."</b>" . " Was Correct";
}
else
{
echo "Doesn't Match!!";
}
}
?>
and the content of image.php is :
<?php
function salt()
{
$sal = "";
for ( $i = 0; $i < 6; $i++ )
{
$sal .= rand(1,9);
}
return $sal;
}
$sal = salt();
header("Content-type: image/gif");
$img = ImageCreate(48,20);
$red = ImageColorAllocate($img, 255, 0, 0);
$white = ImageColorAllocate($img, 255, 255, 255);
ImageString($img, 3, 3, 3, $sal, $white);
ImageGif($img);
ImageDestroy($img);
?>
The problem is simple, after the output of the random image ( which works perfectly ), the script just stop its execution, it is like writing "exit;" after the print of the image , any idea on why is that happening ?
And if i remove the HTML form, and place instead of it any other element, it works, so it is like no HTML forms are allowed in the same page as a GD generated image... so ?
However, I created a text-based one ( and not image ) and it is working perfectly...
Regards