Народ помогите с регистрацией.
<?php
$dbc = mysqli_connect('localhost', 'root', '', 'registr');
if(isset($_POST['send'])){
$username = htmlspecialchars(trim($_POST[username]));
$password = htmlspecialchars($_POST[password]);
$password_2 = htmlspecialchars($_POST[password_2]);
if(!empty($username) && !empty($password) && !empty($password_2) && $password == $password_2){
$query = "SELECT * FROM `registr` WHERE username = '$username'";
$data = mysqli_query($dbc, $query);
if(mysqli_num_rows($data) == 0){
$query = "INSERT INTO `registr` (username, password) VALUES ('$username', '$password')";
mysqli_query($dbc, $query);
echo "All good!";
mysqli_close($dbc);
exit();
}
else{
echo 'Name was registered';
}
}
}
?>
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in W:\domains\Test\index.php on line 11
-
Вопрос задан
-
209 просмотров