What's wrong with this login code? the same code worked in a different website that I programmed
this is the login form:
<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>
this is the login action code:
<?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>";
}
?>
here is the 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);
?>
Please help me ASAP! As I said, I tried the same code in a different website that I programmed and it worked