title: What am I doing wrong in checking if the mail already exist in MySQLI?
body: <p>So, I got a code to check if the mail is already registrated in the users database.. But when I try to register using the same mail as registrated, it don't trigger the code.
  I tried to print the result and I used the code as IsValidUser("themail"); and it returned 1. But still it wont trigger the registration code..
  Here's how I check it;</p>
  
  <pre><code>if(IsValidUser($reg_email) == 1) {
              $result = '&lt;script&gt;var iframe = document.createElement("IFRAME");iframe.setAttribute("src", "data:text/plain,");document.documentElement.appendChild(iframe);window.frames[0].window.alert("Error\nThis mail adress are already registrated.");iframe.parentNode.removeChild(iframe);&lt;/script&gt;';
          }
  </code></pre>
  
  <p>and here's the function;</p>
  
  <pre><code>function IsValidUser($mail) {
  global $conn;
  $sql = "SELECT * FROM users WHERE mail = '$mail'";
  $result = mysqli_query($conn, $sql);
  if(!$result)
      die("Error description: " . mysqli_error($conn));
  if(mysqli_num_rows($result) &gt; 0)
      return 1;
  else
      return 0;
  }
  </code></pre>