I cant get my function to work, I have next code
<?php
function alreadyExists($name) {
require_once "connection.php";
$funcsql = "SELECT * FROM `users` WHERE `name` = ?";
$funcstmt = mysqli_stmt_init($conn);
mysqli_stmt_prepare($funcstmt, $funcsql);
mysqli_stmt_bind_param($funcstmt, "s", $name);
mysqli_stmt_execute($funcstmt);
$rows = mysqli_stmt_num_rows($funcstmt);
if ($rows > 0 ) {
$error1 = "Already exists";
return $error1;
}
}
?>
It is in the functions, and this in the my registration
$error1 = alreadyExists($login);
if (isset($error1)) {
$errors = "User already exists";
}
But it dont work it will register you anyway, where is my error?