Hello All I have the code below that i cant seem to get to work.

At the bottom here you will find my code with a If Else statement. That i just cant get to do what i want. so i am hoping someone can help guide me in the right direction. I am gonna be honest i am VERY new to PHP so please bare with me.

On the first If it checks to make sure that the promocode that was entered is in the database and that part works.

On the second if i want it to look through the database and find the promocode and confirm that there is not an email address associated with that promocode record. Currently it is not doing that i can enter a promo code that has an email or not and it inserts into the DB.

This is where my problem lies am i doing this completely wrong is there a better way to accomplish what i am trying to do here? Or have i just overlooked something small?
PHP Code:
$promosql "SELECT email IS NULL or email = '' has_email FROM formdata WHERE promoCode = '$varPromo'";
$promoraw $mysqli->query($promosql);
$promoraw->num_rows != 1) {
$promo .= "$varPromo is not a valid promocode \n";
            } else {
$row $promoraw->fetch_assoc();
                if (
$row['has_email']) {
// Promo code has been used
$dupe .= "$varPromo has already been used on $varDate \n";
                } else {
// Insert into table
$sql "INSERT INTO formdata (promoCode, name, email, address, city, state, zip, submitDate) VALUES (".
PrepSQL($varPromo) . ", " .
PrepSQL($varName) . ", " .
PrepSQL($varEmail) . ", " .
PrepSQL($varAddress) . ", " .
PrepSQL($varCity) . ", " .
PrepSQL($varState) . ", " .
PrepSQL($varZip) . ", " .
PrepSQL($varDate) . ")";
header("location: index.php?success=1");