【问题标题】:generating a random no.in php [closed]在php中生成一个随机编号[关闭]
【发布时间】:2011-09-07 08:43:05
【问题描述】:

我正在处理一个在线考试应用程序。现在首先学生必须登录,他们会得到问题。现在我想要的是当学生登录然后随机没有。必须在 1 到 50 之间生成。这将为他提取 50 个问题。登录成功时如何生成1到50之间的随机数。

这是我的html代码:

<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>

现在,当登录成功时,随机编号。必须生成 1 到 50 之间的值。

【问题讨论】:

标签: php html random


【解决方案1】:

如果我理解你,你需要使用rand [docs]mt_rand [docs] 函数,例如:

rand(1, 50);

【讨论】:

猜你喜欢
  • 2013-07-19
  • 2014-05-23
  • 2016-08-27
  • 2018-05-20
  • 1970-01-01
  • 2018-03-24
  • 2013-04-24
  • 1970-01-01
  • 2014-02-01
相关资源
最近更新 更多