PHP Session变量比较

:)

I tried to make a game for fun, but I got one problem.

Well, when you open the game, it shows one RAND number. rand(1,20) ..(Min=1 Max=20).. and you got 2 buttons (Smaller) (Bigger)

It has 2 random functions..

So, you have to guess if the next number is higher or lower than the default..

But there is one problem. Program does't compare two random functions properly. :(

<?php
session_start();
?>


<div id="pogodak">
<?php
$rand = rand(1,20);
$rand2 = rand(1,20);



if(isset($_POST['smaller']))
{
    if($rand2<=$rand)
    {
        echo "<font color=#0f0>Succeed</font>";
        $_SESSION['hit']=$_SESSION['hit']+1;
    }   
    else
    {
        echo "<font color=#DE001A>Fail</font>";
        unset($_SESSION['hit']);
        session_destroy;
    }
}
if(isset($_POST['bigger']))
{

    if($rand2>=$rand)
    {
        echo "<font color=#0f0>Succeed</font>";
        $_SESSION['hit']=$_SESSION['hit']+1;
    }   
    else
    {
        echo "<font color=#DE001A>fail</font>";
        unset($_SESSION['hit']);
        session_destroy;
    }
}
session_destroy;
?>
</div>

down there...

    <table width="1000">
<form action="" method="post">
  <tr>
    <td width="321" align="center" valign="middle">
        <input type="submit" name="smaller" value="Smaller" class="button"/></td>

    <td width="348" align="center" valign="middle" class="veliko"><? echo $rand;?></td>

    <td width="315" align="center" valign="middle" class="veliko">
        <input type="submit" name="bigger" value="Bigger" class="button"/></td>

  </tr>
  <tr>
    <td height="83" colspan="3" align="center" valign="middle" class="srednje"><? echo "Hits: " . $_SESSION['hits']"</br>";?></td>
    </tr>
    <tr>
    <td height="83" align="center" valign="middle" >Nickname:</td>
    <td height="83" align="center" valign="middle" ><input type="text" name="name"/></td>
    <td height="83" align="center" valign="middle" ><input type="submit" name="kraj" value="Finish!" />
</td>
    </tr>
    </form>
</table>

$rand and $rand2 gets the same value, try put another seed between the 2 values and check the callback when the numbers have the same value

$rand = rand(1,20);
//srand goes here
$rand2 = rand(1,20);