and i just got a basic registration system for my website, and i can't figure out how to disallow duplicate usernames, can anyone help me?
<?php
if(!empty($_POST['email']) && !empty($_POST['password'])){
$query = "INSERT INTO users (name, email, password) VALUES (:name, :email, :password)";
$stmt = $conn->prepare($query);
$stmt->bindValue(':name', $_POST['name']);
$stmt->bindValue(':email', $_POST['email']);
$stmt->bindValue(':password', password_hash($_POST['password'], PASSWORD_BCRYPT));
if( $stmt->execute() ){
echo 'Success';
} else {
echo 'Failure';
print $stmt->errorCode();
}
}
?>