I have tryed this many many times and i don't get why this don't work. Because of this my registeration pages pass all usernames. I have no idea what is wrong. Sorry about my bad english i am really tired and desperate
function user_exists($username){
$username = htmlspecialchars($username);
$sql = "SELECT username FROM ***** WHERE username = '$username'";
$result = mysqli_query($GLOBALS['$db'], $sql);
if(mysqli_num_rows($result) > 0){
$errors[] = 'Käyttäjätunnus \''. $_POST['username'] . '\' on jo otettu.';
}
}
I am calling that function like this:
if(user_exists($_POST['username']) === true){
$errors[] = 'Käyttäjätunnus \''. $_POST['username'] . '\' on jo otettu.';
}