当我使用正确的用户名和密码登录时,我收到“错误的用户名或密码”错误,数据库连接正常,我认为密码+用户名检查有问题。
<?php
$host="mysql12-int.cp.hostnet.nl"; // Host name
$username="u33936_mick"; // username
$password="//password was correct"; // password
$db_name="db33936_axe"; // Database name
$tbl_name="users"; // Table name
mysql_connect("$host", "$username", "$password");
mysql_select_db("$db_name");
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql = 'SELECT * FROM `users` LIMIT 0, 30 WHERE username="$myusername" and
password="$mypassword"';
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("username");
session_register("password");
header("location:index.php");
} else {
echo "Wrong Username or Password";
}
?>
这是我的表格
<form name="login" method="post" action="login.php">
<fieldset id="inputs">
<input id="myusername" type="text" name="myusername"
placeholder="Username" required="">
<input id="mypassword" type="password" name="mypassword"
placeholder="Password" required="">
</fieldset>
<fieldset id="login.php">
<input type="submit" id="submit" value="Login">
</style>
</fieldset>
</form>