as stated in my username, desperately need help so sorry if its a duplicate post!
I'm trying to do up a login page that redirects me to my home page if authentication fails so my input will cross check with the database(mysql) then output either successful or error. but the result always show error. im pretty sure that it didnt went into my 1st if checking statement.
As shown below is my code:
<?php
$servername = "localhost";
$username = "read";
$password = "projecttest";
$dbname = "test-member";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$password1 = $_POST["password"];
$username1 = $_POST["username"];
$chkpassword = " SELECT password FROM member WHERE password = $password1 ";
$chkusername = " SELECT username FROM member WHERE username = $username1";
if ($conn->query($chkpassword) == TRUE ) {
echo "successful log in"
?>
<INPUT TYPE="hidden" NAME="redirect"
VALUE="http://localhost/IPproject_test1/home.php">
<?php
}
else if ($conn->query($chkpassword) == FALSE ) {
echo "error";
}
$conn->close();
?>