User模塊UserAction.class.php
select();//查詢數據庫
$this->assign('data',$arr);//
$this->display();
}
/*
* 向數據庫插入數據
**/
public function add(){
$m=M('User');
$m->username=$_POST['username'];
$m->sex=$_POST['sex'];
$num=$m->add();
if ($num>0){
$this->success('添加成功','index');//添加成功並返回首頁
}else {
$this->error('添加失敗');
}
}
/*
* 顯示添加表單
**/
public function addform(){
$this->display();
}
}
?>
首頁模板文件index.html
<script> function jump(){ window.location='__URL__/addform'; } </script> ID號 用戶名 性別 操作 {$vo.id} {$vo.username} {$vo.sex} 刪除|修改