tp 框架的增

//增

   public function test()
{
//数据访问 //造模型对象 $nation = D("Nation"); $this->redirect('zhuCe',array(),5,'页面跳转中请稍后....'); } public function zhuCe() { //实现两个逻辑 //1.显示注册页面2.向数据库添加内容 if(empty($_POST)) { //显示页面 $this->show(); } else { $n=D("nation"); $n->create();//自动收集表单必须有post数据 $z=$n->add();//掉add方法实现添加 if($z) { //显示页面 $this->success("添加成功","zhuCe"); $this->redirect('zhuCe',array(),5,'页面跳转中请稍后....'); //5秒钟跳转到zhuce页面 } else { //错误页面的默认跳转是返回前一页,通常不需要设置 $this->error("添加失败!"); } } }
<form action="__ACTION__" method="post">
    <div>代号:<input type="text" name="Code" /></div>
    <div>名称:<input type="text" name="Name" /></div>
    <div><input type="submit" value="添加" /></div>

</form>


 
原文地址:https://www.cnblogs.com/liuran123/p/6230054.html