protected function validate()
 {
     $required = array("admission_number" => "Admission Number", "admission_date" => "Admission Date", "name" => "Name", "class_level" => "Class", "date_of_birth" => "Date of Birth", "gender" => "Gender", "mobile" => "Mobile");
     global $user;
     if ($user->checkAdmin() == true) {
         if (isset($_POST)) {
             foreach ($required as $key => $value) {
                 if (!isset($_POST[$key]) || $_POST[$key] == '' || $_POST[$key] == 'select') {
                     echo $value . ' is Required<br/>';
                     return;
                 }
             }
             if (!is_numeric($_POST['mobile'])) {
                 echo "Mobile number must be Numeric";
             } else {
                 if (isset($_POST['permanent_pincode']) && $_POST['permanent_pincode'] != '' && !is_numeric($_POST['permanent_pincode']) || isset($_POST['correspondence_pincode']) && $_POST['correspondence_pincode'] != '' && !is_numeric($_POST['correspondence_pincode'])) {
                     echo "Pincode must be Numeric";
                 } else {
                     echo 'Saving...';
                     global $objPDO;
                     require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/student_class.php';
                     require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/student_profile_class.php';
                     $student = new Student($objPDO);
                     $studentProfile = new StudentProfile($objPDO);
                     if (!isset($_POST['roll_no']) || $_POST['roll_no'] == '') {
                         $roll_no = rand(1000, 9999);
                     } else {
                         $roll_no = $_POST['roll_no'];
                     }
                     $temp_pass = substr(md5(microtime()), 5, 10);
                     $pass = md5($temp_pass);
                     if ($_POST['category'] == 'select') {
                         unset($_POST['category']);
                     }
                     if ($_POST['blood_group'] == 'select') {
                         unset($_POST['blood_group']);
                     }
                     $acct_type = 'student';
                     $student->setRollNo($roll_no);
                     $student->setPhone($_POST['phone']);
                     $student->setName($_POST['name']);
                     $student->setEmail($_POST['email']);
                     $student->setacctType($acct_type);
                     $student->loadByRoll($roll_no);
                     if ($student->getPassword() == '' || $student->getPassword() == NULL) {
                         $student->setPassword($pass);
                     }
                     $student->save();
                     $id = $student->getID();
                     $studentProfile->setByArray($_POST);
                     $studentProfile->setRollNo($roll_no);
                     $studentProfile->setTempPass($temp_pass);
                     $studentProfile->setUserId($id);
                     $studentProfile->save();
                     echo '<meta http-equiv="Refresh" content="0;url=http://localhost/cloud/parent/addparent/' . $studentProfile->getUserId() . '"/>';
                 }
             }
         }
     } else {
         header('Location:http://localhost/cloud');
     }
 }