Page 1 of 1

rand function

Posted: Tue Dec 15, 2009 9:51 am
by Goofan
Hi i´ve been playing around with random function (rand()) and come up to this... here i get an error:
Notice: Undefined index: Random in C:\Program Files\wamp\www\mine\thomas\random.php on line 2

Code: Select all

 
<?php
if ($_POST["Random"])//Kollar om knappen RANDOM använts.
{
    $number = $number + 1;
 
    if ($number < 10)
        {
        $rand = rand(0,1000);
            if ($rand > 900)
                {
                    echo $rand ."<br>";
                    echo "You Won" .rand(0,30000);
                }
        }
    else
        {
            echo "You have played more then 10 times today";
        }
}
?> 
<input style='width:75;height:25;font-weight:bold' name="Random" type="submit" value="Random">
 
am i doing something wrong? cant figure it out.

Re: rand function

Posted: Tue Dec 15, 2009 10:19 am
by McInfo
1. Line 3 should be

Code: Select all

if (isset($_POST["Random"]))
2. Where are the <form> tags?

Edit: This post was recovered from search engine cache.

Re: rand function

Posted: Tue Dec 15, 2009 10:24 am
by Goofan
oh ok line 3 :D
the form i had only forgotten ...


thanks