This is my database Database img
Imagine the blurred text is simply "test".
I have a basic login/signup form which inserts their data into a database. I want to make sure you can't have 2 users with the same email address, I've tried the following code, but for some reasons, it ignores this and just lets me create an account with the same email. How would I edit this code to make it show an error if you pick an email that someone else has used? Any help is appreciated.
$exist = mysqli_query($conn, "SELECT * FROM username WHERE username='".$username."'");
if(mysqli_num_rows($exist) > 0){
die("email already exists");
}
Here is my $conn
.
$conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);
The connection to the DB works fine.