如何将$ _POST [“fname”],...的结果与表中的记录进行比较?

The student enters his credentials to a from:

<form action="index.php" id="courseform" method="post">
Enter Your First Name: <input type="text" name="fname"><br><br>
Enter Your Last Name: <input type="text" name="lname"><br><br>
Enter Your Student Number: <input type="text" name="student_nr"><br><br>
  <input type="submit">
</form>

I have a table with the student records as under:

Database changed
mysql> explain student;

    +-----------+-------------+------+-----+---------+-------+
    | Field     | Type        | Null | Key | Default | Extra |
    +-----------+-------------+------+-----+---------+-------+
    | id        | char(6)     | NO   | PRI | NULL    |       |
    | firstname | varchar(30) | NO   |     | NULL    |       |
    | lastname  | varchar(30) | NO   |     | NULL    |       |
    | email     | varchar(50) | YES  |     | NULL    |       |
    +-----------+-------------+------+-----+---------+-------+

4 rows in set (0.05 sec)

How can i verify the 3 values 'fname', 'lname' and 'id'(=student_nr) entered into the form are valid entire, i.e: exist in the table?

I tried the following, but did not work:

<?php
include 'parameter_conn.php';
$link = mysqli_connect("$server","$user","$pass","$db");

if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }else {
      echo "Connection Successful" . "<br>";
  }

if (isset($_POST['fname'],$_POST['lname'],$_POST['student_nr'])) { 
 $fname = $_POST["fname"]; 
 $lname = $_POST["lname"];
 $student_nr = $_POST["student_nr"]; 
}
$result_student = mysqli_query($link, "SELECT * FROM student");
$rows_student = mysqli_num_rows($result_student);

if($fname === $result_student['firstname'] && $lname === $result_student['lastname'] && $student_nr === $result_student['id']) {
    echo 'found';
} else {
    echo 'not found';
}

You can use a where clouse in your sql statement and simply check if you get a matching row. Please note below is very insecure and prone to SQL Injection (https://en.wikipedia.org/wiki/SQL_injection) but it illustrates the purpose. Consider using PDO

$fname = $POST['fname'];
$email = $POST['email'];
// .. all other fields

$sql = "SELECT id, firstname, lastname, email FROM studentsTable WHERE firstname='".$fname."' AND lastname='".$lname."' AND email='".$email."'";

$result = $conn->query($sql);

if ($result->num_rows > 0) {
  // match found
} else {
  // no match
}