我正在使用php登录表单,每次尝试登录时都说“#34;您输入的用户名未找到。"我在我的代码中有一个if语句,我认为它是因为我没有将某些内容链接到mySQL。我已经在这方面工作了几天而且无法修复它!请你帮帮我吧谢谢 - 约翰
<?
$form = "<form action='./login.php' method='post'>
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='user' /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password' /></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='loginbtn' value='Login' /></td>
</tr>
</table>
</form>";
if ($_POST['loginbtn']){
$user = $_POST['user'];
$password = $_POST['password'];
if ($user){
if ($password){
require("connect.php");
$password = md5(md5("ak3sfx".$password."58ghy7"));
//Make sure login info is good
$query = mysql_select_db("users");
if ($numrows == 1){
$row = mysql_fetch_assoc($query);
$dbuser = $row['users'];
$dbpassword = $row['password'];
if ($password == $dbpassword){
//Set session info
$_SESSION['username'] = $dbusers;
echo "You have been logged in as <b>$dbuser</b> <a href='./member.php'>Click here</a> to continue";
}
else
echo "You did not enter the right password. $form";
}
else
echo "The username you entered was not found. $form";
mysql_close();
}
else
echo"You must enter your password. $form";
}
else
echo"You must enter your username. $form";
}
else
echo $form;
?>
答案 0 :(得分:0)
mysql_select_db(“users”)会将db更改为用户。您是否尝试从用户表中选择数据?如果是这样,您需要更改此行。
看看这个链接。 http://php.net/manual/en/function.mysql-fetch-assoc.php 这些例子可以帮助你