Here is my php login code where i have problem with my condition. I think.
<?php
session_start();
$servername = "localhost";
$username = "root";
$password = "";
$mysql_database = "practiceLogin";
$conn = mysqli_connect($servername, $username, $password) or die ("Connection failed: " . mysqli_connect_error());
mysqli_select_db($conn,$mysql_database) or die("Opps some thing went wrong");
if (isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['Password'];
$stmt = $conn->prepare("SELECT * FROM tbl_account WHERE uName = ? AND uPassword = ?");
$stmt->bind_param('ss',$username,$password);
$stmt->execute();
$get_result=$stmt->get_result();
$row_count= $get_result->num_rows;
$stmt->close();
$conn->close();
if ($row_count>0){
$_SESSION['User_name'] = $username;
echo "Login Success!";
exit();
}else{
echo "Wrong username and password";
exit();
}
}
?>
<html>
<head>
<title>Login</title>
</head>
<body>
<form action = "?" method = "POST">
<input type = "text" name="username"><br>
<input type = "password" name = "password"><br>
<input type = "submit" name = "submit" value = "Login"></br>
<a href = "register.php">Create Account</a>
</form>
</body>
</html>
Everytime I login to this i always go to the else statment which is Wrong username and password always showing up even i have the right credentials? What am I missing?
I don't need to hash my password at this time i just need an answer if i can have a successful login page. Thanks