<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus?"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> <script> function jump(){ window.location="http://localhost:8080/thinkphp/index.php/User/add"; } </script> </head> <body> <h1>scan show 你好 hhhello world</h1> <table border='1' width='500' align='center'> <tr> <th>id</th> <th>username</th> <th>sex</th> <th>操作</th> </tr> <volist name='data' id='vo'> <tr> <td><{$vo.id}></td> <td><{$vo.username}></td> <td><{$vo.sex}></td> <td><a href="http://localhost:8080/thinkphp/index.php/User/del/id/<{$vo.id}>">删除</a>|<a href="http://localhost:8080/thinkphp/index.php/User/modify/id/<{$vo.id}>">修改</a></td> </tr> </volist> </table> <center> <button onclick="jump()">添加用户</button> </center> </body> </html> 添加用户按钮,调用 window.location="http://localhost:8080/thinkphp/index.php/User/add"; public function add(){ $this->display(); } 跳转到一个增加用户的页面 <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus?"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> </head> <body> <form action="__URL__/create" method='post'> id:<input type='text' name='id' /></br> 姓名:<input type="text" name='username' /></br> 性别:男<input type='radio' name='sex' value='1' > 女<input type='radio' name='sex' value='0'></br> <input type="submit" value='添加用户'/></br> </form> </body> </html> add.html 里调用__URL__/create 方法: public function create(){ $m=M('user'); $m->id=$_POST['id']; $m->username=$_POST['username']; $m->sex=$_POST['sex']; $idnum=$count=$m->add(); if ($idnum){ $this->success('数据添加成功','index'); #$this->success('数据添加成功'); }else{ $this->error('数据添加失败'); } }