This code checks my login form-
PHP Code:
<?php
session_start();
if (isset($_POST["username"])) {
require "../database.php";
$valid = false;
$username = $_POST["username"];
$pass = $_POST["pass"];
$check = mysql_query("SELECT * FROM users WHERE username = $username AND password = $pass") or die(mysql_error());
$check2 = mysql_num_rows($check);
if ($check2 == 1) {
$valid = true;
}
if ($valid) {
$_SESSION["user"] = $username;
header("Location: ../members");
} else header("Location: error");
}
?>
The code is coming up with this error when you enter nothing into the username and password inputs
Code:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND password =' at line 1
And this error when you enter test as a username and test2 as the password
Code:
Unknown column 'test' in 'where clause'
Any help?
Bookmarks