function doInsert() { if (isset($_POST['savefaculty'])) { if ($_POST['name'] == "" or $_POST['address'] == "" or $_POST['email'] == "") { message("All field is required!", "error"); check_message(); } else { $inst = new Instructor(); $name = $_POST['name']; $address = $_POST['address']; $Gender = $_POST['Gender']; $civilstats = $_POST['civilstats']; $specialization = $_POST['specialization']; $email = $_POST['email']; $empStats = $_POST['empStats']; $user = new User(); $acc_name = $_POST['name']; $acc_username = $_POST['username']; $acc_password = $_POST['pass']; $acc_type = 'Teacher'; $resuser = $user->find_all_user($acc_name); if ($resuser >= 1) { message("Account name already exist!", "error"); redirect('index.php'); } else { $res = $inst->find_all_instructor($name); if ($res >= 1) { message("Instructor name already exist!", "error"); check_message(); } else { $inst->INST_FULLNAME = $name; $inst->INST_ADDRESS = $address; $inst->INST_SEX = $Gender; $inst->INST_STATUS = $civilstats; $inst->SPECIALIZATION = $specialization; $inst->INST_EMAIL = $email; $inst->EMPLOYMENT_STATUS = $empStats; $user->ACCOUNT_NAME = $name; $user->ACCOUNT_USERNAME = $email; $user->ACCOUNT_PASSWORD = sha1($acc_password); $user->ACCOUNT_TYPE = $acc_type; $istrue = $user->create(); if ($istrue == 1) { //message("New [". $acc_name ."] created successfully!", "success"); //redirect('index.php'); } } $istrueee = $inst->create(); if ($istrueee == 1) { message("New Instructor created successfully!", "success"); redirect('index.php'); } else { message("No Instructor created!", "error"); redirect('index.php'); } } } } }
$updateDone = true; Instructor::updateLname($instructorId, $newInstructorLname); } if (!$updateDone) { throw new Exception("No new data inputted. Process aborted."); } // header('Location: ' . BASE_URL . 'academia/instructors/success'); } else { throw new Exception("Either you're trying to hack this app or something wrong went. In either case the\n developers were just notified about this."); } } else { if (isBtnSavePrsd()) { $newInstructorFname = trim($_POST['f_name']); $newInstructorLname = trim($_POST['l_name']); Instructor::create($newInstructorFname, $newInstructorLname); header('Location: ' . BASE_URL . 'academia/instructors/success'); exit; } else { if (isBtnDeletePrsd()) { Instructor::delete($_POST['delInstructorIdModal']); header('Location: ' . BASE_URL . 'academia/instructors/success'); exit; } } } } catch (Exception $e) { $errors[] = $e->getMessage(); } /** * http://stackoverflow.com/a/4128377/2790481