I'm trying to make a login system and user registration in PHP, but I have several problems only in login.php, the registration is working correctly, but the login is presenting the errors: Warning: mysqli_query () () expects parameter 1 to be mysqli, null given in C: \ wamp \ www \ rifa \ login.php on line 13 and Warning: mysqli_num_rows () expects parameter 1 to be mysqli_result, null given in C: \ wamp \ www \ rifa \ login.php on line 14 , my code is just below, does anyone have an idea how I can fix these errors?
<?php
error_reporting (E_ALL & ~ E_NOTICE & ~ E_DEPRECATED);
$hostname = 'localhost';
$username = 'root';
$password = '12345';
$db = 'rifou';
$connection = new mysqli($hostname, $username, $password);
mysqli_select_db($connection, $db);
$nickname = mysqli_real_escape_string($connection, $_POST['nick']);
$password = mysqli_real_escape_string($connection, $_POST['senha']);
$select_user = "SELECT * FROM usuarios WHERE nick='$nickname' AND senha='$senha'";
$run_user = mysqli_query($con, $select_user);
$check_user = mysqli_num_rows($run_user);
if ($check_user > 0){
echo "logado";
} else {
echo "não logado";
}
?>