public function insert()
{
header('Content-Type:text/html; charset=utf-8');//防止出现乱码
$user=$_POST['user'];
$this->verifyCheck();
$Pagemodel = D("user");
$vo = $Pagemodel->create();
if(false === $vo) die($Pagemodel->getError());
$topicid = $Pagemodel->add(); //add方法会返回新添加的记录的主键值
if($topicid)
{
//$_SESSION[C('USER_AUTH_KEY')]=$user;//不能用此句
Session::set(C('USER_AUTH_KEY'),$user);
//dump(Session::get('authId'));
echo "<script>alert('数据库添加成功');location.href='http://127.0.0.1/zhuce/index.php/index';</script>";
}
else throw_exception("<script>alert('数据库添加失败');history.back();</script>");
public function index()
{
if(!Session::is_set(C('USER_AUTH_KEY')))
//if(!isset($_SESSION['USER_AUTH_KEY'])||($_SESSION['USER_AUTH_KEY']==0))//不能用此句
{
$msg="用户没有登录";
}
else
{
$msg=Session::get(C('USER_AUTH_KEY')).'欢迎你回来';
}
$this->assign('msg',$msg);
$this->display();
}
<body>
{$msg}<br />
这是我的首页
</body>