check username and email already exists in php mysql,I have check every input is empty or not and if there is no empty then check username and password is already in databas
you've put this in wrong if condition
$sql="select * from account_info where (username='$username' or email='$email');";
$res=mysqli_query($conn,$sql);
if (mysqli_num_rows($res) > 0) {
// output data of each row
$row = mysqli_fetch_assoc($res);
if ($username==$row['username'])
{
echo "Username already exists";
}
elseif($email==$row['email']) // change it to just else
{
echo "Email already exists";
}
else{
echo "alright"; // don't put it here
}
}
To print the alright put your else outside the if and change elseif to just else like this :
$sql="select * from account_info where (username='$username' or email='$email');";
$res=mysqli_query($conn,$sql);
if (mysqli_num_rows($res) > 0) {
// output data of each row
$row = mysqli_fetch_assoc($res);
if ($username==$row['username'])
{
echo "Username already exists";
}
else($email==$row['email'])
{
echo "Email already exists";
}
} else{ // if condition ends here if it is new entry, echo will work
echo "alright";
}