I've created a PHP server and connected it to a Amazon RDS MySQL database to store and manage user accounts.
A few days after I've launched my server I've noticed some rows with the same email address.
When I'm inserting a new user I'm checking if that email already exists so that I can specifically avoid this problem.
function userExists($email) {
global $DATABASE;
$rows = $DATABASE->GetRows('users', 'email = \'' . $email . '\'');
if($rows->num_rows >= 1) {
return true;
} else {
return false;
}
}
I'm managing to duplicate this by sending multiple requests very quickly. I guess this happens when the client got a really bad internet connection or is really far away.
What would be the best approach to get rid of this problem?
Thank you!