After hitting 'log-in' in a simple login.php, it outputs an 'Object Not Found' and having the link 'localhost/post?username=asd&password=asd&Submit=Log+In'. Can anyone help me find out what's wrong?
Here's the coding to the initial page login.php
<!DOCTYPE html>
<html>
<?php $error=""; //sets the error var to empty?>
<head></head>
<body>
<form name="form1" method="check_login.php" action="post">
Username <input name="username" type="text" id = "username" placeholder="Username">
<br><br>
Password <input name="password" type="password" id = "password" placeholder="********">
<br><br>
<input name="Submit" type="submit" value="Log In">
<br><br>
</form>
</body>
</html>
Here's check_login.php
<?php
//sets the host/username/password/database name into variables
$host = "localhost";
$user = "root";
$pass = "enterpasshere";
$myDB = "abc";
$error = "";
if (empty($_POST['username']) || empty($_POST['password'])) {
$error = "Username or Password is invalid";
}
else
{
$username = $_POST['username']; //gets the username input
$password = $_POST['password']; //gets the password input
$connection = mysql_connect($host, $user, $pass); //connects to the database
mysql_select_db($myDB); //selects the database
$result = mysql_num_rows(mysql_query("SELECT * FROM user WHERE username='$username' AND password='$password'")); //performs the query and gets the number of rows
if($result == 1){ //if the query was right
header("location: home.php");//Redirecting to other page
} else {
$error = "Wrong username or password";
}
mysql_close(); //Make sure to close out the database connection
}
?>
I used to have the form's action as ?php ($_SERVER["PHP_SELF"]);? and the code in the check_login.php inside login.php but I had the problem with error printing so I thought I'll just do this.