My php code generates a random bank account number when registering a user.
When $wszystko_ok == true
, let him register.
This code checks if the generated number already exists in the database. If it exists, set $wszystko_ok = false
and it doesn't agree to the account registration.
How can I make it generate a random number again in this case?
$wszystko_ok == true
$r_nrkonta = rand(1000000000, 9999999999);
$rezultat2 = $polaczenie->query("SELECT nrkonta FROM kontabankowe WHERE nrkonta='$r_nrkonta'");
if (!$rezultat2)
throw new Exception($polaczenie->error);
$ile_takich_nrkonta = $rezultat2->num_rows;
if ($ile_takich_nrkonta > 0)
{
$wszystko_ok = false;
}