This question already has an answer here:
Hi im trying to do a very simple login system using php and mysql, it can be nonsecure
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\LOGIN TEST\login.php on line 18}
I followed the same exact guide from the internet and i still get this error ^
This is my following codes
<?php
$username = "root";
$password = "";
$hostname = "localhost";
$dbhandle = mysql_connect($hostname, $username, $password) or die("Could not connect to database");
$selected = mysql_select_db("login", $dbhandle);
$myusername = $_POST['user'];
$mypassword = $_POST['pass'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$query = "SELECT * FROM admin WHERE Username='$myusername' and Password='$mypassword'";
$result = mysql_query($query);
$count = mysql_num_rows($result);
if($count==1) {
echo 'It worked';
}
?>
btw mysql is nonsecure
i also tried to input this code from this link
and i still got the same error....
this is my index.php
<body>
<form action="login.php" method="POST">
<p>Username:</p><input type="text" name="user" />
<p>Password:</p><input type="password" name="pass" />
<br />
<input type="submit" value="Login" />
</form>
</body>
this is the video which i followed
</div>