<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends BaseController {
    public function changepassword(){
		if(IS_POST){
			//执行ajax
			$old_password=I('old_password','','md5');
			$new_password=I('new_password','','md5');
			$map['id']=session('admin_id');
			$admin=M('admin')->where($map)->find();
			if($admin['password']==$old_password){
				$res=M('admin')->where($map)->setField('password',$new_password);
				if($res){
						$data['status']=1;
						$data['message']='更新成功';
						$this->ajaxReturn($data);
					}else{
						$data['status']=0;
						$data['message']='更新失';
						$this->ajaxReturn($data);
						}
				}else{
					$data['status']=0;
					$data['message']='更新失败，密码错误';
					$this->ajaxReturn($data);
					}
			}else{
				$this->display();
		
			}
		}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
			
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
