Can someone please tell me how to fix this? here is the code
function getPosts()
{
$posts = array();
$posts[0] = $_POST['course'];
$posts[1] = $_POST['level'];
$posts[2] = $_POST['section'];
return $posts;
}
if (isset($_POST['insert'])) {
$data = getPosts();
$existing_Query ="SELECT * FROM `class` WHERE `course`='$data[0]' OR `level`='$data[1]' OR `section`='$data[2]'";
$existing_Result = mysqli_query($con, $existing_Query);
if(0 < mysqli_num_rows ($existing_Result)){
echo '<script type="text/javascript">
alert("your entry is already in the class. please choose another class.");
window.location="addclass.php";
</script>';
} else {
$insert_Query = "INSERT INTO `class` (`course`, `level`, `section`) VALUES ('$data[0]', '$data[1]', '$data[2]')";
$insert_Result = mysqli_query($con, $insert_Query);
if ($insert_Result) {
Thanks.