I do not know how to direct to the same page, in personal.php if the user entered the same FirstName, MiddleName, LastName, and LastSchoolAttended. My current happenings in my code is that, the page is directing to exam.php even though there is the same record, but the record is not adding in the database. So, I want to create an error or design that the user will know if they entered the same entries.
This is my personal.php
<form action = "exam.php" method = "POST">
<tr>
<td> <h3> First Name: </td>
<td> <input type = "text" name = "FirstName" placeholder = "First Name" maxlength = "40" autofocus required> </h3> </td>
</tr>
<tr>
<td> <h3> Middle Name: </td>
<td> <input type = "text" name = "MiddleName" placeholder = "Middle Name" maxlength = "40" required> </h3> </td>
</tr>
<tr>
<td> <h3> Last Name: </td>
<td> <input type = "text" name = "LastName" placeholder = "Last Name" maxlength = "40" required></h3> </td>
</tr>
<tr>
<td> <h3> Age: </td>
<td> <input type = "number" name = "Age" value = "" placeholder = "Age" maxlength = "2" min = "16" required></h3> </td>
</tr>
<tr>
<td> <h3> Home Address: </td>
<td> <input type = "text" name = "HomeAddress" placeholder = "Barangay / Street / Province / City" maxlength = "60" required></h3> </td>
</tr>
<tr>
<td> <h3> Contact Number: </td>
<td> <input type = "tel" name = "ContactNumber" placeholder = "Ex. 9123456789 / 123-456-7" maxlength = "10" required></h3> </td>
</tr>
<tr>
<td> <h3> Last School Attended: </td>
<td> <input type = "text" name = "LastSchoolAttended" placeholder = "Last School Attended" maxlength = "60" required> </h3> </td>
</tr>
</table>
</form>
This is my exam.php
<?php
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); // Turn on mysqli exeptions. Much better than errors.
$conn = new mysqli('localhost', 'root', "", 'studentsinformation'); //Initialize Db connection
$FirstName = $_POST['FirstName'];
$MiddleName = $_POST['MiddleName'];
$LastName = $_POST['LastName'];
$Age = $_POST['Age'];
$HomeAddress = $_POST['HomeAddress'];
$ContactNumber = $_POST['ContactNumber'];
$LastSchoolAttended = $_POST ['LastSchoolAttended'];
This is my query.
$sql = "SELECT * FROM personal where FirstName = '$FirstName' And MiddleName = '$MiddleName' And LastName = '$LastName' And LastSchoolAttended = '$LastSchoolAttended';