<?phpnamespace Admin\Controller;
use Think\Controller;
class PassChangeController extends CommController {
private $oldpassword;
private $username;
private $password;
private $spassword;
public function editPassPage(){
$this->display();
}
public function postForm(){
$this->getFormValue();
$result=$this->check($this->username,$this->oldpassword);
if($result){
if($this->password==$this->spassword){
$admin=M("admin_user");
$id=session("ad_id");
$relt=$admin->where(array("adu_id"=>$id))->save(array("ad_name"=>$this->username,"ad_password"=>md5($this->password)));
if($relt){
$this->success("修改成功!",U("Index/index"));
}else{
$this->success("修改失败!");
}
}else{
$this->success("确认密码不正确!");
}
}else{
$this->success("原用户名或密码不正确!");
}
}
public function getFormValue(){
$this->oldpassword=I("post.oldpassword");
$this->username=I("post.username");
$this->password=I("post.password");
$this->spassword=I("post.spassword");
}
public function check($username,$password){
$admin=M("admin_user");
$where["ad_name"]=$username;
$where["ad_password"]=md5($password);
$ad=$admin->where($where)->find();
if($ad){
return true;
}else{
return false;
}
}
}