This should be handled using a UNIQUE key, remove this function completely from here and everywhere. Just make the `email` column of the `users` table UNIQUE at the MySQL database.