日期:2014-05-17  浏览次数:20518 次

TP 更新数据
PHP code

       //个人档案
public function geren(){
    if(!isset($_SESSION[C("USER_AUTH_KEY")])){
     $msg="请登录";
    }else{
     $msg=$_SESSION[C("USER_AUTH_KEY")];
    }
    $this->assign('msg',$msg);
//==================获取登录信息============================
        $gr=M("admin");
        $baide=$gr->select();
        $this->assign("baide",$baide);
        $this->assign("title",'极限互动办公自动化系统');
        $this->display();
}
public function upgr(){//修改edit 内容
     header("Content-Type:text/html; charset=utf-8");
     $Form = M("admin");
     $data['id'] = $_GET['id'];
     $data['name'] = $_GET['name'];
     $data['password'] = $_GET['password'];
     $data['sex'] = $_GET['sex'];
     $data['bumen'] = $_GET['bumen'];
     $data['TEL'] = $_GET['TEL'];
     $data['QQ'] = $_GET['QQ'];
     $data['email'] = $_GET['email'];
     $data['dizhi'] = $_GET['dizhi'];
     $data['img'] = $_GET['img'];
     if($data){
         $upgr=$Form->where('id='.$data['id'])->save($data);
         if($upgr){
            echo "<script type='text/javascript'>alert('更新成功');window.navigate('geren');</script>";
        }else{
            echo "<script type='text/javascript'>alert('更新失败');window.navigate('geren');</script>";
        }
    }
}


获取HTML 信息
HTML code

<volist name="baide" id="baide">
  <tr>
    <td>{$baide.name}</td>
    <td>{$baide.sex}</td>
    <td>{$baide.TEL}</td>
    <td>{$baide.QQ}</td>
    <td>{$baide.email}</td>
    <td>{$baide.dizhi}</td>
    <td><img src="../../{$baide.img}" width="25" height="30"/></td>
    <td>
            <a href="__URL__/upgr/id/{$baide.id}">编辑档案</a>
    </td>
    </tr>
</volist>


我要更新的内容
HTML code

<volist name="baide" id="baide">
<form action="__URL__/upgr" method="get" name="geren">
<table width="200" border="1">
  <tr>
    <td width="44">姓名</td>
    <td width="140"><input type="text" name="name" value="{$baide.name}" /></td>
  </tr>
  <tr>
    <td width="44">密码</td>
    <td width="140"><input type="text" name="password" value="{$baide.password}" /></td>
  </tr>
  <tr>
    <td>性别</td>
    <td><input type="text" name="sex" value="{$baide.sex}" /></td>
  </tr>
  <tr>
    <td>公司职位</td>
    <td><input type="text" name="weizhi" value="{$baide.weizhi}" /></td>
  </tr>
  <tr>
    <td>公司部门</td>
    <td><input type="text" name="bumen" title="{$baide.bumen}" value="{$baide.bumen}" /></td>
  </tr>
  <tr>
    <td>TEL</td>
    <td><input type="text" name="TEL" value="{$baide.TEL}" /></td>
  </tr>
  <tr>
    <td>QQ</td>
    <td><input type="text" name="QQ" value="{$baide.QQ}" /></td>
  </tr>
  <tr>
    <td>Email</