rand function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

rand function

Post 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.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: rand function

Post 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.
Last edited by McInfo on Thu Jun 17, 2010 3:46 pm, edited 1 time in total.
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: rand function

Post by Goofan »

oh ok line 3 :D
the form i had only forgotten ...


thanks
Post Reply