I have this part of code where I have my $row_count
is always returning a value of 0 even i have the right username and password.
if (isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
$stmt = $conn->prepare("SELECT * FROM users WHERE uName = ? AND uPassword = ?");
$stmt->bind_param('ss',$username,$password);
$stmt->execute() or die ($stmt->error);
$get_result=$stmt->get_result();
print_r($get_result); //DEBUG purpose
$row_count= $stmt->num_rows;
print_r($row_count); die;// DEBUG purpose
$stmt->close();
$conn->close();
if ($row_count>0){
$_SESSION['uName'] = $username;
echo "Logged in";
exit();
}else{
echo "Wrong credentials";
exit();
}
}
btw, i have more rows on my tables does that affect the whole process? My code is always going to the else statment.
mysqli_result Object ( [current_field] => 0 [field_count] => 10 [lengths] => [num_rows] => 0 [type] => 0 )
this is how i determined its always returning as 0. Thanks for your help no need of hashing the passwords just need to return a value of >1
thanks. :D
<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">
<a href = "register.php">Create Account</a>
</form>
</body>
</html>
This is the form.