我初学php做了个带mysql的登陆系统老是不对不知道哪出的问题请高手指点
代码如下:<html>
<head><title>登陆</title></head>
<body> <form action = "denglu.php" method = "post">
用户名: <input type="text" name = "username" /><br/>
密码: <input type="text" name = "userpassword" /><br/>
<input type="submit" value = "denglu" /><br>
</form>
</body>
<html>denglu.php页面<?php
$usern = $_post['username'];
$userpassword=$_post['userpassword'];
echo"$usern ,$userpassword";
$link = mysql_connect('localhost','root','123');
mysql_select_db("mylibrary");
$sql = "select * from userpwd where user='$usern'";
$result = mysql_query($sql);
$row = mysql_fetch_rows($result);
if($row[pass]==$userpassword)
echo "欢迎登陆";
else echo "你的用户名和口令不正确";
?>
代码如下:<html>
<head><title>登陆</title></head>
<body> <form action = "denglu.php" method = "post">
用户名: <input type="text" name = "username" /><br/>
密码: <input type="text" name = "userpassword" /><br/>
<input type="submit" value = "denglu" /><br>
</form>
</body>
<html>denglu.php页面<?php
$usern = $_post['username'];
$userpassword=$_post['userpassword'];
echo"$usern ,$userpassword";
$link = mysql_connect('localhost','root','123');
mysql_select_db("mylibrary");
$sql = "select * from userpwd where user='$usern'";
$result = mysql_query($sql);
$row = mysql_fetch_rows($result);
if($row[pass]==$userpassword)
echo "欢迎登陆";
else echo "你的用户名和口令不正确";
?>
mysql_fetch_rows??????????????
改为mysql_fetch_array!!!!!!!!!!!!
mysql_fetch_row,这个函数是从结果集中取一行作为枚举数据,从和指定的结果标识关联的结果集中取得一行数据并作为数组返回。每个结果的列储存在一个数组的单元中,偏移量从 0 开始。 注意,这里是从0开始偏移,也就是说不能用字段名字来取值,只能用索引来取值,所以如下代码是取不到值的:mysql_fetch_array,从结果集中取得一行作为关联数组,或数字数组,或二者兼有,除了将数据以数字索引方式储存在数组中之外,还可以将数据作为关联索引储存,用字段名作为键名。 也就是说他得到的结果像数组一样,可以用key或者索引来取值,
$sql = "select * from userpwd where user='$usern' and pass='$userpassword'";
$result = mysql_query($sql);
$row = mysql_num_rows($result);
if($row>0)
echo "欢迎登陆";
else echo "你的用户名和口令不正确";
$userpassword=$_post['userpassword']; 这里的post要改成大写的POST$usern = $_POST['username'];
$userpassword=$_POST['userpassword'];