Использую вот такой код для регистрации, но выдаёт ошибки. Вот сам код:
<?php
$login = filter_var(trim($_POST['login_name']),
FILTER_SANITIZE_STRING);
$email = filter_var(trim($_POST['email']),
FILTER_SANITIZE_STRING);
$pass = filter_var(trim($_POST['login_password']),
FILTER_SANITIZE_STRING);
$passr = filter_var(trim($_POST['password-repeat']),
FILTER_SANITIZE_STRING);
$pass = md5($pass."S12");
$mysqli = require __DIR__ . "\db.php";
$result = mysqli_query("SELECT * FROM `user` WHERE `login` = '$login' OR `mail` = '$email'");
if (mysqli_num_rows($result) > 0) {
echo
"<script> alert('Логин или почта уже были взяты'); </script>";
}
else{
if ($pass == $passr) {
$sql = "INSERT INTO `user` (`login`, `mail`, `password_hash`) VALUES ('$login', '$email', '$pass')";
$stml = $mysqli->stmt_init();
$stmt->prepare($sql);
print_r($_POST);
var_dump($pass);
}
}
?>
Ошибки:
Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\OSPanel\domains\site\register.php on line 14
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\OSPanel\domains\site\register.php on line 15