<?php
    $course=$yos=$block=$exam="";
    if(isset($_POST['search1'])){
        /*//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*/
        
        $course = clean($_POST['course']);
        $yos = clean($_POST['yos']);
        $block = clean($_POST['block']);
        $exam = clean($_POST['exam']);
        
        if(!$course){
            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(!$yos){
            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 year of study</span>
                </div>';
        }else
        if(!$block){
            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 block</span>
                </div>';
        }else
        if(!$exam){
            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(" ","_",$exam);
            echo "<script type='text/javascript'> document.location = 'view-results.php?status=1&c=$course&y=$yos&s=$block&e=$ex'; </script>";
            exit();
        }
    }
?>