title: function to check if data is on the database
body: <p>I create a function to find all firstname and lastname in my database all I want if that data is already exist I just want to output, error message</p>
  
  <p>my question is how to create a function to check if data is already exist?</p>
  
  <p>this is my function to find all data of firstname and lastname.</p>
  
  <pre><code>function find_student_by_firstname($firstname){
    global $con;
  
    $safe_firstname = prep($firstname);
  
    $sql  = "SELECT * ";
    $sql .= "FROM studeprofile ";
    $sql .= "WHERE FirstName = '{$safe_firstname}' ";
    $sql .= "LIMIT 1";
    $student_set = mysqli_query($con, $sql);
    confirm_query($student_set);
    if($student = mysqli_fetch_assoc($student_set)){
      return $student;
    } else {
      return null;
    }
  }
  
  function find_student_by_lastname($lastname){
    global $con;
  
    $safe_lastname = prep($lastname);
  
    $sql  = "SELECT * ";
    $sql .= "FROM studeprofile ";
    $sql .= "WHERE LastName = '{$safe_lastname}' ";
    $sql .= "LIMIT 1";
    $student_set = mysqli_query($con, $sql);
    confirm_query($student_set);
    if($student = mysqli_fetch_assoc($student_set)){
      return $student;
    } else {
      return null;
    }
  }
  </code></pre>
  
  <p>this is my current function to check if data is already exist.</p>
  
  <pre><code>function match_fistname_lastname($lastname, $firstname){
    $student_firstname = find_student_by_firstname($lastname);
    if($student_firstname){
      find_student_by_lastname($lastname);
    } else {
      return false;
    }
  }
  </code></pre>