Is this code correct? Or should I keep using } else { for (errors) until the end?
if ($y = $link->prepare('SELECT id, password FROM usuarios WHERE username = ?')){
$y->bind_param('s', $_POST['username']); $y->execute(); $y->store_result();
if ($y->num_rows > 0){ echo 'Username exists, please choose another!';
} else {
if ($y = $link->prepare('SELECT id, password FROM usuarios WHERE email = ?')){
$y->bind_param('s', $_POST['email']); $y->execute(); $y->store_result();
if ($y->num_rows > 0){ echo 'Email exists, please choose another!'; exit;
}
if (strlen($_POST['password']) > 25 || strlen($_POST['password']) < 6){
echo 'Password must be between 6 and 25 characters long!'; exit;
}
Another question, is it possible to find the code below and displaying different error messages?