• php 跳转控制


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

  • 相关阅读:
    PHP的资源类型
    windows 配置 apache的多个站点
    php 压缩数据存储
    php统计图类库JpGraph
    php之ThinkPHP的memcached类的修改
    linux 安装报错:pkg-config not found
    Mysql清空表(truncate)与删除表中数据(delete)的区别
    【MySQL】查看MySQL配置文件路径及相关配置
    phper
    http 同步异步请求
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350599.html
Copyright © 2020-2023  润新知