public function login_supervisor() { if (isset($_POST[tpl_supervisor::username() . '_sup']) && isset($_POST[tpl_supervisor::password() . '_sup'])) { $username = $_POST[tpl_supervisor::username() . '_sup']; $password = $_POST[tpl_supervisor::password() . '_sup']; if (!empty($username) && !empty($password)) { $db = new data_base(tpl_supervisor::supervisor(), array(tpl_supervisor::id(), tpl_supervisor::name()), array(tpl_supervisor::username() => $username, tpl_supervisor::password() => $this->hash_password($password), tpl_supervisor::active() => 1)); $data = $db->get_where(); if (!empty($data)) { $session = new session_supervisor(); $session->new_login_supervisors(); $session->set_id_user($data[0][tpl_supervisor::id()]); if ($session->get_login_supervisors()) { echo json_encode(array('valid' => true, 'title' => 'Welcome !!', 'massage' => $data[0][tpl_supervisor::name()])); } else { echo json_encode(array('valid' => false, 'title' => 'Oops !!', 'massage' => 'Was not username & password, please try again')); } } else { echo json_encode(array('valid' => false, 'title' => 'Oops !!', 'massage' => 'Was not username & password, please try again')); } } else { echo json_encode(array('valid' => false, 'title' => 'Oops !!', 'massage' => 'Was not username & password, please try again')); } } else { echo json_encode(array('valid' => false, 'title' => 'Oops !!', 'massage' => 'Was not username & password, please try again')); } }
public function update() { $id = $_POST[tpl_supervisor::supervisor() . '_' . tpl_supervisor::id() . '_update']; $name = $_POST[tpl_supervisor::supervisor() . '_' . tpl_supervisor::name() . '_update']; $id_college = $_POST[tpl_supervisor::supervisor() . '_' . tpl_supervisor::id_college() . '_update']; $id_university = $_POST[tpl_supervisor::supervisor() . '_' . tpl_supervisor::id_university() . '_update']; $username = $_POST[tpl_supervisor::supervisor() . '_' . tpl_supervisor::username() . '_update']; $db = new data_base(tpl_supervisor::supervisor(), array(tpl_supervisor::name() => $name, tpl_supervisor::id_college() => $id_college, tpl_supervisor::id_university() => $id_university, tpl_supervisor::username() => $username), array(tpl_supervisor::id() => $id)); $results = $db->change(); if ($results) { echo json_encode(array('valid' => 1, 'title' => 'Successfully !!', 'massage' => 'I\'ve been Update ' . $name)); } else { echo json_encode(array('valid' => 0, 'title' => 'Oops !!', 'massage' => 'Was not Update ' . $name . ', please try again')); } }
</div> <div class="form-group"> <label for="Edit_NameCategory"><?php echo tpl_supervisor::username() . ' ' . tpl_supervisor::supervisor(); ?> : </label> <input type="text" class="form-control" id="<?php echo tpl_supervisor::supervisor() . '_' . tpl_supervisor::username() . '_update'; ?> " name="<?php echo tpl_supervisor::supervisor() . '_' . tpl_supervisor::username() . '_update'; ?> "/> </div> <div class="form-group"> <label>College <?php echo tpl_supervisor::supervisor(); ?> : </label> <select name="<?php echo tpl_supervisor::supervisor() . '_' . tpl_supervisor::id_university() . '_update'; ?> " id="<?php echo tpl_supervisor::supervisor() . '_' . tpl_supervisor::id_university() . '_update';