<?php
    $course1=$classYoS=$classSem=$exam1="";   
    if(isset($_POST['search2'])){
        /*//Function to sanitize values received from the form. Prevents SQL injection
        function clean($str) {
    		$str = @trim($str);
    		if(get_magic_quotes_gpc()) {
    			$str = stripslashes($str);
    		}
    		return mysql_real_escape_string($str);
    	}*/
        /*end of function*/
        
        $course1 = clean($_POST['course1']);
        $classYoS = clean($_POST['classYoS']);
        $classSem = clean($_POST['classSem']);
        $exam1 = clean($_POST['exam1']);
        
        if(!$course1){
            echo'<div class="alert alert-danger absolue center text-center" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                    <span class="text-danger">Select course</span>
                </div>';
        }else
        if(!$classYoS){
            echo'<div class="alert alert-danger absolue center text-center" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                    <span class="text-danger">Select Current Class year of study</span>
                </div>';
        }else
        if(!$classSem){
            echo'<div class="alert alert-danger absolue center text-center" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                    <span class="text-danger">Select Current Class block</span>
                </div>';
        }else
        if(!$exam1){
            echo'<div class="alert alert-danger absolue center text-center" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                    <span class="text-danger">Select exam category</span>
                </div>';
        }else
        {
            $ex=str_replace(" ","_",$exam1);
            echo "<script type='text/javascript'> document.location = 'view-results.php?status=2&c=$course1&y=$classYoS&s=$classSem&e=$ex'; </script>";
            exit();
        }
    }
?>