目前,I m正在测试一个简单的标识系统I ve。 文字是核对我数据库中的用户名和密码一,如果两者都吻合,则用户名称与会议变量。 当我只读“成员”一页时,它将检查一下,如果会议没有变数,用户就不能看内容。 似乎按预期开展工作。 基于上述内容,我的问题是:
我的方法有哪些弱点/缺陷?
Can cookies make it more secure? If so, how would it do so with relation to my code?
这里指的是我迄今所做的工作:
用户名和密码核对:
<?
session_start();
$username = $_POST[ username ];
$password = $_POST[ password ];
if ($username && $password){
$query = mysql_query("SELECT * FROM user WHERE username= $username ");
$numrows = mysql_num_rows($query);
//if user exists
if ($numrows !=0){
while ($row = mysql_fetch_array($query)){
$dbusername = $row[ username ];
$dbpassword = $row[ password ];
}
if ($username == $dbusername && md5($password) == $dbpassword){
echo You re in! <a href="member.php">Click</a> here to enter the member page. ;
$_SESSION[ username ] = $dbusername;
}
else
echo "incorrect password!";
}
else
die("sorry, that user doesn t exist!");
}
?>
页: 1
<?
session_start();
if ($_SESSION[ username ]){
echo "Welcome, ".$_SESSION[ username ]."!<br>
<a href= changepassword.php >Change password</a>
";
}
else{
echo "please log in";
}
?>