大家好=)我正在尝试为我的网站登录,实际上登录工作正常。但是我决定添加一个“第一次用户”按钮,然后询问用户的临时 ID。(考虑到我们在一家公司,每个人都只为了这个目的而收到一个 id)
如果 id 是正确的(它在数据库中),则用户会进入“首次创建个人资料”网站,但是......我在解释方面遇到了重大问题。无论我尝试什么组合,mysql 都会让我失望,就好像我给出的任何内容都不正确。
这是我的简单 HTML 输入 + 按钮
<html>
<body>
<form action="first_id_check.php" method="POST" >
<p> Please input your given id into the box below </p>
<input type="text" name="id">
<input type="submit">
</form>
这是应该完成工作的php脚本
<?php
$contab = mysql_connect('localhost', 'root') or die ("Cannot connect to DB");
$condb = mysql_select_db('info', $contab);
$temp = $_POST['id'];
$query = "SELECT * FROM tempid WHERE Number='$temp'";
$result = mysql_query($query);
$count = mysql_num_rows($result);
if ($result == 1)
{
header("location:first_create.php");
}
else
{
echo "Error, please try again";
sleep(5);
header("location:index.php");
}
?>
“数字”是存储 id 的列的名称。但无论我输入什么,我总是被重新路由到“index.php”,好像结果总是返回 0 >.< 我该如何解决这个问题?