Exemple #1
0
 public function find_student_login()
 {
     if (isset($_POST['number']) && isset($_POST['password'])) {
         if (!empty($_POST['number']) && !empty($_POST['password'])) {
             $this->use->use_model('data_base');
             $this->use->use_lib('table/tpl_students');
             $tpl = new tpl_students();
             $db = new data_base($tpl->table(), array($tpl->id()), array($tpl->id_students() => $_POST['number'], $tpl->password() => md5($_POST['password'])));
             $data = $db->get_where();
             if (!empty($data)) {
                 $this->use->use_lib('site/sessions');
                 $session = new sessions();
                 if ($session->new_login()) {
                     $session->info_user($data);
                     return json_encode(array('valid' => true, 'massage' => '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>welcome Back </strong></div>'));
                 } else {
                     return json_encode(array('valid' => false, 'massage' => '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>Error login</strong></div>'));
                 }
             } else {
                 return json_encode(array('valid' => false, 'massage' => '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>Incorrect password or ID number </strong></div>'));
             }
         } else {
             return json_encode(array('valid' => false, 'massage' => '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>The field is required and can\'t be empty</strong></div>'));
         }
     } else {
         return json_encode(array('valid' => false, 'massage' => '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>The field is required and can\'t be empty</strong></div>'));
     }
 }
 public function login_student()
 {
     if (isset($_POST['username_stu']) && isset($_POST[tpl_students::password() . '_stu'])) {
         $username = $_POST[tpl_students::username() . '_stu'];
         $password = $_POST[tpl_students::password() . '_stu'];
         if (!empty($username) && !empty($password)) {
             $db = new data_base(tpl_students::students(), array(tpl_students::id(), tpl_students::first_name()), array(tpl_students::username() => $username, tpl_students::password() => $this->hash_password($password), tpl_students::status() => 1));
             $data = $db->get_where();
             if (!empty($data)) {
                 $session = new session_students();
                 $session->new_login_students();
                 $session->set_id_user($data[0][tpl_students::id()]);
                 if ($session->get_login_students()) {
                     echo json_encode(array('valid' => true, 'title' => 'Welcome !!', 'massage' => $data[0][tpl_students::first_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_password()
 {
     $id = $_POST[tpl_students::students() . '_' . tpl_students::id() . '_update_password'];
     $password = $_POST[tpl_students::students() . '_' . tpl_students::password() . '_update_password'];
     $db = new data_base(tpl_students::students(), array(tpl_students::password() => md5($password)), array(tpl_students::id() => $id));
     $results = $db->change();
     if ($results) {
         echo json_encode(array('valid' => 1, 'title' => 'Successfully !!', 'massage' => 'I\'ve been Update ' . $id));
     } else {
         echo json_encode(array('valid' => 0, 'title' => 'Oops !!', 'massage' => 'Was not Update ' . $id . ', please try again'));
     }
 }
 public function update_students()
 {
     $this->use->use_model('data_base');
     $this->use->use_lib('table/tpl_students');
     $tpl = new tpl_students();
     $data = array($tpl->id_students() => $_POST['id_student_u'], $tpl->first_name() => $_POST['first_name_u'], $tpl->last_name() => $_POST['last_name_u'], $tpl->id_college() => $_POST['name_college_u']);
     if (!empty($_POST['password_u'])) {
         $data[$tpl->password()] = md5($_POST['password_u']);
     }
     if (!empty($_POST['name_specialty_u'])) {
         $data[$tpl->id_specialty()] = $_POST['name_specialty_u'];
     }
     $db = new data_base($tpl->table(), $data, array($tpl->id() => $_POST['id_update']));
     echo json_encode(array('valid' => $db->change(), 'massage' => '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button><h4>Alert!</h4> <strong>Update success </strong></div>'));
 }
?>
"
                               name="<?php 
echo tpl_students::students() . '_' . tpl_students::password() . '_update_password';
?>
"/>
                    </div>

                    <div class="form-group">
                        <label for="">Retype New Password <?php 
echo tpl_students::students();
?>
 : </label>
                        <input type="text" class="form-control"
                               id="<?php 
echo tpl_students::students() . '_' . tpl_students::password() . '_r_update_password';
?>
"
                               name="<?php 
echo tpl_students::students() . '_' . tpl_students::password() . '_r_update_password';
?>
"/>
                    </div>
                    <button type="submit" class="btn btn-success" id="update" name="update">Save</button>
                </form>
                </br>
                <div class="" id="result_massages_update_password"></div>
            </div>
        </div>
    </div>
</div>
"
                               name="<?php 
echo tpl_students::students() . '_' . tpl_students::password();
?>
"/>
                    </div>

                    <div class="form-group">
                        <label for="">Password re: </label>
                        <input type="password" class="form-control"
                               id="<?php 
echo tpl_students::students() . '_' . tpl_students::password() . '_re';
?>
"
                               name="<?php 
echo tpl_students::students() . '_' . tpl_students::password() . '_re';
?>
"/>
                    </div>


                    <div class="form-group">
                        <label>University : </label>
                        <select name="<?php 
echo tpl_students::students() . '_' . tpl_students::id_university();
?>
"
                                id="<?php 
echo tpl_students::students() . '_' . tpl_students::id_university();
?>
"