I've been working since yesterday to try and establish a simple login form for my MySQL database, I have a table set up as tbl_Users which contains all the necessary columns that would be required for a user. To test it out I populated the table with one row to test out my form. But no matter how many times I keep trying. I keep getting the echo message telling me it's invalid. I know it's not invalid because I copy and pasted the details from the table into the input boxes, so it must be something I'm doing wrong with the code. But when I look and compare the code with the guide that helped me, everything matches properly. I'm really stuck here!
ConnectorCode.php
The connector code file works fine, as I've tested it individually. I have it included in the main index file so that I wouldn't have to write it out on each page.
<?php
$conn = mysqli_connect("localhost", "b4014107", "Win1", "b4014107_db2")or 
die(mysqli_connect_error())
echo "Connection Successful<br>";
$db= mysqli_select_db("b4014107_db2", $conn) or die("Could not select _db2");
echo "Connection to _db1 database succsessful<br>";
?>
Index.php
As you can see I'm using the updated Mysqli commands within both my connector code and my index code. I've established a connection to the database and am calling the data from tbl_Users. Everything works format wise, the page displays the boxes and forms properly. But what fails to work is the actual login. I keep getting the fail echo I set up as else echo.
<?php
echo mysqli_error($conn)
error_reporting(E_ALL & ~E_NOTICE);
session_start();
if($_POST['submit']) {
include_once("ConnectorCode.php");
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);
$sql = "SELECT User_id, User_Name, Password FROM tbl_Users WHERE User_Name ='$username' AND User_level ='1' LIMIT 1";
$query = mysqli_query($conn, $sql);
if ($query) {
    $row = mysqli_fetch_row($query);
    $userid = $row[0];
    $dbUsername = $row[1];
    $dbPassword = $row[2];
}
if($username == $dbUsername && $password == $dbPassword) {
    $_SESSION['User_Name'] = $username;
    $_SESSION['User_id'] =$userid;
    header('Location: user.php');
} else {
        echo "Incorrect Username or Passsword";
        }
}
?>
 <!DOCTYPE HTML>
 <html>
 <head>
 <title> Login Page </title>
 </head>
 <body>
 <h2> Login Page </h2>
 <form method ="post" action="index.php">
 <input type="text" placeholder="Username" name ="username" /> <br />
 <input type="password" placeholder="Password" name="password" /> <br />
 <input type="submit" name="submit" value ="Login" />
 </form>
 </body>
 </html>
I'm assuming maybe it's something to the connection to the columns in the database. I was unsure if maybe I'm labelling some fields incorrect in some manner.
CREATE TABLE `tbl_Users` (  `User_id` int(11) NOT NULL auto_increment,  
`First_Name` varchar(32) NOT NULL,  
`Last_Name` varchar(32) NOT NULL,  
`Email` varchar(100) NOT NULL, 
 `User_Name` varchar(100) NOT NULL,  
`Password` varchar(100) NOT NULL,  
`User_level` int(11) NOT NULL,  
`Tickets_id` int(11) NOT NULL,  
PRIMARY KEY  (`User_id`),  KEY `Tickets_id` (`Tickets_id`),  
CONSTRAINT `tbl_Users_ibfk_1` FOREIGN KEY (`Tickets_id`) REFERENCES `tbl_Tickets` (`Tickets_id`)) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
