Im having a problem with my login form, my coding on the login page
I am getting the "Couldn't execute query" when one logs in from the login page.
Thanks if you can help.
Code:
<html>
<head>
<title>Admin Login</title>
</head>
<body>
<h1>Admin Login</h1>
<form method="post" action="admin.php">
<table width=50%>
<tr>
<td>Username:</td>
<td><input type="text" name="username" size="25" maxlength="50"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="text" name="password" size="25" maxlength="50"></td>
</tr>
</table>
<input type="submit" name="submit" value="Login">
</form>
</body>
</html>
[code]
and then the page that authenticates it:
[code]
<?
if ((!$username) || (!$password)) {
header ("Location[URL unfurl="true"]http://opushi/test/admin-login.php");[/URL]
exit;
}
$db_name = "accessories";
$connection = @mysql_connect("localhost","root") or die ("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection) or die ("Couldn't select database.");
$sql = "SELECT * FROM admin WHERE username = \"$username\" AND password = \"$password\")";
$result = @mysql_query($sql, $connection) or die ("Couldn't execute query.");
$num = mysql_numrows($result);
if ($num != 0) {
$msg = "Congratulations! You're authorized!";
} else {
header("Location: [URL unfurl="true"]http://opushi/test/admin-login.php");[/URL]
exit;
}
?>
<body>
<? echo "$msg"; ?>
I am getting the "Couldn't execute query" when one logs in from the login page.
Thanks if you can help.