Original Post
I am brand new to php, and figured I would start with a simple "Petals Around the Rose" game. For those of you not familiar with this riddle, you can check it out here . Anyway, here is what I have so far, minus the parts that would give away the answer to the riddle. greenX.gif is a picture of a green die displaying the number represented by X. In other words, green5.gif would be a picture of a green die showing 5 dots. Ok, at some point, it calculates the answer, and stores it in, can you guess? That's right, $answer. Now, I want to give the user a nice little text box they can type in their guess, hit submit, and have php compare $guess with $answer, and tell them if they are right or wrong. But I am not sure how to go about this. I understand how to make the text box, and how to submit what is in the text box($guess) to another php page, but how do I send $answer? Thanks for any help you can provide. [Edited by - mrtie_dye on March 20, 2005 4:30:17 PM]
<?php
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());
$randval = rand();
$answer = 0;
$diceside = array(1 => rand(1,6), 2 => rand(1,6), 3 => rand(1,6), 4 => rand(1,6), 5 => rand(1,6));
for ($i = 1; $i <= 5; $i++)
{
if($diceside[$i] == 1)
{
?>
<img src="green1.gif">
<?php
}
elseif($diceside[$i] == 2)
{
?>
<img src="green2.gif">
<?php
}
elseif($diceside[$i] == 3)
{
?>
<img src="green3.gif">
<?php
}
elseif($diceside[$i] == 4)
{
?>
<img src="green4.gif">
<?php
}
elseif($diceside[$i] == 5)
{
?>
<img src="green5.gif">
<?php
}
elseif($diceside[$i] == 6)
{
?>
<img src="green6.gif">
<?php
}
}
?>