Im doing a simple LOGIN program using PHP and MYSQL, where the user inserts their username and password, and clicks the submit button. their data will then be checked against MYSQL database ("mydatabase", table is "user") and will let them in if their data is correct... now, my program does not seem to work?? im pretty sure i`ve missed something out... all i need is just a very simple "LOGIN PAGE" thats all, could anyone help please..
thank you..
here is the code of my php file "login.php"
<html>
<head>
<title>Login page</title>
</head>
<body>
<?php
$hostname = "localhost";
$username = "";
$password = "";
$database = "mydatabase";
$db_connection = mysql_connect($hostname, $username, $password) or die ("DB server failed".mysql_error());
$db_select = mysql_select_db($database) or die ("DB connection to $database failed".mysql_error());
if (isset($submit)){
$sql =mysql_query ("SELECT * FROM user WHERE username = '$username' AND password = '$password'");
if (($username == '$username') || ($password == '$password'))
{
print "Logged in.";
}
else {
print "Error !";
}
}
?>
<form action="<?=$PHP_SELF ?>" method="post">
User ID : <input type="text" name="user_id" size="22" maxlength="15" /><br/>
Password : <input type="password" name="password" size="22" maxlength="15" /><br/><br/>
<input type="submit" name="submit" value="Submit">
<input type="reset" name="reset" value="Clear all">
</form>
</body>
</html>