这个登录代码有什么问题?相同的代码在我编写的不同网站中工作
这是登录表单:
<html>
<head>
<meta http-equiv="content-type" content-type="text/html; charset=windows-1255">
<title>היכנס!</title>
</head>
<body dir="rtl">
<center>
<form action="loginaction.php" method="post">
שם משתמש:<input type="text" name="username" value=""><br>
סיסמה:<input type="password" name="password" value=""><br>
<input type="submit" value="היכנס!"><br>
</form>
<br>
<?php
$error=$_GET['error'];
if ($error==1) {
echo "שם המשתמש או הסיסמה לא נכונים!";
}
;
?>
</center>
</body>
</html>
这是登录操作代码:
<?php
include('config.php');
$username=$_GET['username'];
$password=$_GET['password'];
$userpassword=md5($password);
$checkquery=mysql_query("SELECT * FROM `users` WHERE `username`='$username' AND `password`='$userpassword'");
if (mysql_num_rows($checkquery)>0) {
$row=mysql_query("SELECT `userid` FROM `users` WHERE `username`='$username' AND `password`='$userpassword'");
$data=mysql_fetch_array($row);
$userid=$data['userid'];
setcookie("userid", $userid);
setcookie("username", $username);
setcookie("userpassword", $userpassword);
echo "<script type=\"text/javascript\">window.location='index.php';</script>";
} else {
echo "<script type=\"text/javascript\">window.location='login.php?error=1';</script>";
}
?>
这是config.php:
<?php
$link=mysql_connect("mysql9.000webhost.com", "a2803040_dbase", "I won't publish the password here");
mysql_select_db("a2803040_dbase", $link);
mysql_set_charset("utf8", $link);
?>
请尽快帮助我!正如我所说,我在我编写的另一个网站上尝试了相同的代码并且它有效