示例#1
0
 public function find_users_login()
 {
     if (isset($_POST['username']) && isset($_POST['password'])) {
         if (!empty($_POST['username']) && !empty($_POST['password'])) {
             $this->use->use_model('data_base');
             $this->use->use_lib('table/tpl_users');
             $tpl = new tpl_users();
             $db = new data_base($tpl->table(), array($tpl->id()), array($tpl->username() => $_POST['username'], $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_admin()) {
                     $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 username </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>'));
     }
 }
示例#2
0
 public function update_user()
 {
     $this->use->use_model('data_base');
     $this->use->use_lib('table/tpl_users');
     $tpl = new tpl_users();
     $data = array($tpl->username() => $_POST['username_update']);
     if (!empty($_POST['password_update'])) {
         $data[$tpl->password()] = md5($_POST['password_update']);
     }
     $db = new data_base($tpl->table(), $data, array($tpl->id() => $_POST['id']));
     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>'));
 }
    <h2 class="sub-header">Users table</h2>
    <div id="toolbar">
        <button id="add_new_user" class="btn btn-success btn-xs">New</button>
    </div>
    <div class="table-responsive">
        <table id="table" data-toggle="table" data-url="<?php 
echo site_url('admin/find_all_users_table_ajax');
?>
"
               data-cache="false" data-height="400" data-show-refresh="true" data-show-toggle="true"
               data-show-columns="true" data-pagination="true" data-page-list="[5, 10, 20, 50, 100, 200]"
               data-search="true" data-flat="true"  data-toolbar="#toolbar">
            <thead>
            <tr>
                <th data-field="<?php 
echo $tpl_users->id();
?>
" data-halign="center" data-sortable="true"> ID</th>
                <th data-field="<?php 
echo $tpl_users->username();
?>
" data-halign="center" data-sortable="true"> Username</th>
                <th
                    data-field="operate"
                    data-formatter="operateFormatter"
                    data-events="operateEvents"
                    data-align="center"
                    >Action
                </th>

            </tr>