php 跳转控制

本文介绍了一个基于ThinkPHP框架的用户管理系统实现过程。通过HTML页面展示用户信息,并提供了添加、删除及修改用户的功能。文章详细展示了如何使用PHP进行数据库操作,包括数据的增删改查等基本操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!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('数据添加失败');
	 }
	  
 }

转载于:https://www.cnblogs.com/zhaoyangjian724/p/6199710.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值