I am relatively new to PHP, but I know some. I am trying to make a login system but the login function doesn't seem to be working. I am doing a check rows command and checking if it is = to 1, but it is saying that it isn't = to 1. " Warning: mysql_num_rows() expects parameter 1 to be resource, object given in C:\xampp\htdocs\message\login.php on line 25 "
I know that this would be because it has not found a matching value but I have checked the database and the username and password is definitely in there.
Any help would be greatly appreciated.
Code is below:
<html>
<head>
<title>Login - Messaging</title>
</head>
<body>
<?php include "connect.php"; ?>
<?php include "functions.php"; ?>
<?php include "header.php"; ?>
<div>
<form method="post">
<?php
if(isset($_POST['submit'])){
$username=$_POST['username'];
$password=$_POST['password'];
if($username === '' || $password === ''){
$message="One or more of the fields are empty";
} else {
$password1=md5(hash("sha512",$password));
$checklogin = mysqli_query($con,"SELECT * FROM `users` WHERE `username`='$username' AND `password`='$password1'");
$check2=mysql_num_rows($checklogin);
if($check2==1){
$message="Successful!";
header("location: index.php");
} else {
$message="Incorrect Username or Password";
}
}
echo "<p>$message</p>";
}
?>
Username: <input type="text" name="username" /><br>
Password: <input type="password" name="password" /><br>
<input type="submit" name="submit" value="Login" />
</form>
</div>
</body>
</html>