I'm currently trying to ensure no duplicate emails are allowed to be entered within my mySQL database, I've marked stud_email as unique within the database I'm just struggling to alert the message. This is what I've got so far, am I on the correct path?
if (isset($_POST['submit'])) {
$email = $_POST['email'];
$check = mysqli_query($conn, "SELECT * FROM students WHERE stud_email = '$email'");
$checkrows = mysqli_num_rows($check);
if ($checkrows > 0) {
echo '<script>alert("Student email already exists")</script>';
} else {