生成一个随机的no.in php [关闭]

I am working in an application which is a online examination application. Now at first the students has to login and they will get the questions. Now what i want is when the students login then a random no. must be generated between 1 to 50. And that will extract 50 questions for him. How to generate the random number between 1 to 50 when the login is successful.

This is my html code:

<body>
<h3>Login Form</h3>
<form id="form1" name="form1" method="post" action="login.php">
  Student Username: 
  <label>
  <input type="text" name="username" id="username" />
  </label>
  <p>Student Password: 
    <label>
    <input type="text" name="password" id="password" />
    </label>
  </p>
  <p>
    <label>
    <input type="submit" name="button" id="button" value="login" />
    </label>
  </p>
</form>
</body>

Now when the login is successful then a random no. between 1 to 50 must be generated.

if i understand you, you need to use rand [docs] or mt_rand [docs] functions like:

rand(1, 50);