title: Make a function to check if user exists
body: <p>So i try to make a function for my register site to check if a username, email or ip exists. And like to check them seperat. So i can output to the user that what exists. But somehow this isn`t working.
  <BR>
  <br>
  So now its checked ok but doesn't pass for a other name.
  <br>
  This is the function.<br>
  function.php file</p>
  <pre><code>  function checkExists($con, $username, $email, $ip) {
      //check for existing stuff
      $userCheck = &quot;SELECT * FROM users WHERE username = ? OR email = ? OR ip = ?&quot;;
      $check = mysqli_stmt_init($con);
      
      if(!mysqli_stmt_prepare($check, $userCheck)) {
          $errors = &quot;sql not working!&quot;;
      }
      
      mysqli_stmt_bind_param($check, &quot;ssi&quot;, $username, $email, $ip);
      mysqli_stmt_execute($check);
      
      $resultData= mysqli_stmt_get_result($check);
      
      if($row = mysqli_fetch_assoc($resultData)) {
          $username = $row['username'];
          return $username;
          $email = $row['email'];
          return $email;
          $ip = $row['ip'];
          return $ip;
      }
      mysqli_stmt_close($check);
      
    }
  </code></pre>
  <p>register.php file<br>
  And here is the way i like to check it:</p>
  <pre><code>        elseif(checkExists($con, $username, $email, $ip) === $username) {
              $errors = &quot;Username does already exists!&quot;;
          }
  
  </code></pre>