I'm creating an educational platform in which courses (course codes) are created. I want to be able to prevent a new course code from being inserted ignoring the case being used or use of whitespace. e.g if "PHY 101" already exists and one types in "phy101". It should reject the new entry.
$new_course = $_POST['new_course'];
$sql = mysqli_query($conn, "SELECT * FROM courses WHERE course = '$new_course'") or die(mysqli_error($conn));
$num_row=mysqli_num_rows($sql);
if($num_row === 1){
echo "<script>
alert('Course code already exists.');
window.location = 'create_newcourse.php';
</script>";
}