一、页面分析
$userid = $_SESSION['userid'];
$admin_username = param::get_cookie('admin_username'); $page = $_GET['page'] ? intval($_GET['page']) : '1' ; $pages = $this->db->pages; $data= $this->db->listinfo(); include $this->admin_tpl('product_list');if(is_array($data)){
foreach($data as $info){ ?>
<?php } ?>
<?php } ?>一、增加
public function add() {
if(isset($_POST['dosubmit'])) {//声明一个数组
$info = array();//判断用户名
if(!$this->op->checkname($_POST['info']['username'])){ showmessage(L('admin_already_exists')); } $info = checkuserinfo($_POST['info']); if(!checkpasswd($info['password'])){ showmessage(L('pwd_incorrect')); }//判断密码
$passwordinfo = password($info['password']); $info['password'] = $passwordinfo['password']; $info['encrypt'] = $passwordinfo['encrypt']; //删除多余的字段 $admin_fields = array('username', 'email', 'password', 'encrypt','roleid','realname'); foreach ($info as $k=>$value) { if (!in_array($k, $admin_fields)){ unset($info[$k]); } }//添加
$this->db->insert($info);//获取最后一次添加记录的主键号
if($this->db->insert_id()){ showmessage(L('operation_success'),'?m=admin&c=admin_manage'); } } else { $roles = $this->role_db->select(array('disabled'=>'0')); include $this->admin_tpl('admin_add'); } }