在form表单提交页面的时候(既要显示,又可以修改提交)
public function personInfo(){
$user=M("UserInfo");
if(empty($_POST)){
$list=$user->where(array('uid'=>$_SESSION['uid']))->find();$this->list=$list;
$this->display();
} else{
//获取数据,验证数据,修改保存数据,读出数据
$email=I('post.email','');
$tel_phone=I('post.tel_phone','');
$gender=I('post.gender','');
//需要对数据检验
$arr=array(
'email' =>$email,
'tel_phone' =>$tel_phone,
'gender' =>$gender,
);
$user->where(array('uid'=>$_SESSION['uid']))->save($arr);
$list=$user->where(array('uid'=>$_SESSION['uid']))->find();
$this->list=$list;
// $this->display(); 使用这个后,页面只是会刷新而已,form表单里面post数据仍然在,
//所以不会进入到上面的判断,用下面的方法from表单数据则不存在
}
}
本文介绍了一个PHP程序中如何实现表单数据的显示与修改提交功能,包括数据的获取、验证、修改保存以及重新加载页面等内容。
4850

被折叠的 条评论
为什么被折叠?



