form表单如下,
<form action="http://localhost/think/zpf_think/xiangmu/index.php/User/modify/" method="post">
<input type="hidden" name="id" value="<{$data.id}>">id<br />
<input type="text" name="username" value="<{$data.username}>">用户名<br />
性别:男<input type='radio' name='sex' value='1' />
女<input type='radio' name='sex' value='0' /><br/>
<input type="submit" value="提交修改">
</form>
</pre><pre name="code" class="html">模型如下:
<pre name="code" class="php"> public function modify(){
$m=M('User');
$data['id']=$_POST['id'];
$data['username']=$_POST['username'];
$data['sex']=$_POST['sex'];
$count=$m->save($data);
if($count>0){
$this->success('数据修改成功','index');
}else{
$this->error('数据修改失败');
}
}
}
</pre><pre name="code" class="php">发现页面一直在数据修改成功和数据修改失败两个页面跳转,跟着视频学着,发现由于form表单中的action中多了一个'/'造成的,
所以把form表单中的action路径改为<pre name="code" class="html"><form action="http://localhost/think/zpf_think/xiangmu/index.php/User/modify" method="post">
就可以了
</pre><pre>