Why is my email check variable returning an error as undefined

     

I am validating my signup form using ajax. Can someone please answer why I am getting an error: Undefined variable: emailcheck. it is clearly defined in the line before it. Thank you. Here is the code below.



  if (isset($_POST['submit'])) {
$first = $_POST['first'];   $last = $_POST['last'];   $email = $_POST['email'];   $pwd = $_POST['pwd'];
$errorEmpty = false;   $errorEmail = false;

if (empty($first) || empty($last) || empty($email) || empty($pwd)) {   echo "";   $errorEmpty = true;   }
elseif (!filter_var($email FILTER_VALIDATE_EMAIL)) {   echo "";   $errorEmail = true;   }
  else {   $sql = "SELECT email FROM user WHERE email='$email'";   $result = mysqli_query($conn $sql);   $emailcheck = mysqli_num_rows($result);  }
  if ($emailcheck > 0) {   echo "";   $errorEmail = true;   }

else {   $encryptpwd = password_hash($pwd