I'm looking at various resources in order to understand how to create user logins for a website, but every time I try something goes wrong. Specifically...well below is my code, where specifically this line "$numrows = mysql_num_rows($query);" gives me the error "Warning: mysqli_stmt_num_rows() expects parameter 1 to be mysqli_stmt, string given" and I have no clue how to fix this. If someone could help it'd be greatly appreciated. Connection to the database works fine, it's that one line though that gives me grief.
Code:$myusername = $_POST['username']; $mypassword = $_POST['pass']; if ($myusername && $mypassword) { $connection = @new mysqli($host, $username, $password, $db_name); if ($connection->connect_error) { die('Connect Error' . $connection->connect_error); } else { echo 'Successfully Connected to the Database'; $query = "SELECT * FROM logins WHERE username = '$username'"; $numrows = mysql_num_rows($query); if ($numrows !=0) { while($rows = mysql_fetch_assoc($query)) { $db_username = $row['username']; $db_password = $row['password']; } if ($myusername == $db_username && $mypassword == $db_password) { echo "Login Successful"; } else { echo "The username and/or password were incorrect"; } } } }


Reply With Quote
Bookmarks