generating a random no.in php [closed]
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this questionI 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="use开发者_开发问答rname" />
</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);
精彩评论