Examples of submitting forms and action forms in ThinkPhp3.2

Source: Internet
Author: User
Examples of submitting forms and action forms in ThinkPhp3.2

Go ahead and build a watch ————

And then put the things I entered into the table:


<input type= "Submit" id= "Tijiao" value= "Submit" style= "Background-color: #fa6374; Color: #FFF; Cursor:pointer; border:0px; margin-left:63px; " >

Use the Submit button here to form the way

The form is written like this:


<form action= "{: U (' Validate ')}" method= "Post" name= "MyForm" >

Then we go to the Validate method to do the processing:


<?php Public    function validate () {        $date [' name '] = I (' post.lc_name ');        $date [' tel '] = I (' Post.lc_tel ');        $date [' youxiang '] = I (' Post.lc_email ');        $date [' address '] = I (' post.lc_address ');        $date [' content '] = I (' post.lc_content ');        $yzm = I (' Post.code ');//        $fkyz = D ("Liuyan");/**/////if        (! $fkyz->create ()) {////            If creation failure means validation failed Output error message//            exit ($fkyz->geterror ());////        }else{            //Verify that other data operations can be performed            $verify = new \think\ Verify ();                        $yzmyz = $verify->check ($YZM);                        if (! $yzmyz) {                            $this->error (' captcha error ');            }                        else{                            $validate = M ("liuyan3");                            $validate->add ($date);                            $this->success (' Add success ');            }        } //    }

I am commenting on the validation;

So what I'm typing is stored in the data sheet,

I also need to walk them out in the background, and I'll take control of it.

Convenience is simple:


<article:list type= "liuyan3" limit= "order=" id ASC "where=" ">        <tr>            <td>{$v. id}</td >            <td>{$v .name}</td>            <td>{$v .tel}</td>            <td>{$v. youxiang}</td >            <td>{$v .address}</td>            <td>{$v .content}</td>            <td>                <a href= "__controller__/xg?code={$v. ID}" >                    <i></i> Edit </a>&nbsp;&nbsp;                <a>                    <i></i> Delete </a>            </td>        </tr>    </article:list>

Then make a change:

Modify the XG method connected to the controller and pass the ID;

Take a look at Ajax processing, Ajax simple


<script> var config = {'. Chosen-select ': {},} for (var selector in config) {$ (selector    ). Chosen (Config[selector]);        } deal ();                    Function Deal () {$ ("#btn_s"). Click (function () {var id=$ ("#ids"). Val ();                    var name=$ ("#laiyuan"). Val ();                    var tel=$ ("#laiyuan2"). Val ();                    var email=$ ("#views"). Val ();                    var address=$ ("#laiyuan_url"). Val ();            var content=$ ("#liuyan"). Val ();            alert (content);            alert (ID);            alert (name);            alert (email);            alert (address); $.ajax ({url: "__controller__/deal", Data:{id:id,name:name,tel:tel,email:email,address:addres                S,content:content}, DataType: "TEXT", type: "POST", Success:function (R)                {window.location.href= "__controller__/index";  }          })})}</script></body> 

Then background processing:


<?public function xg ()    {            $id =i (' Get.code ');            $this->assign ("arr2", $id);            $this->display (' tg:public/xg ');    }        Public Function Deal ()    {            $id =i (' post.id ');            $data [' Name ']=i (' post.name ');            $data [' Tel ']=i (' Post.tel ');            $data [' Youxiang ']=i (' post.email ');            $data [' Address ']=i (' post.address ');            $data [' Content ']=i (' post.content ');            $db =m (' liuyan3 ');            $r = $db->where ("id= ' {$id} '")->save ($data);d UMP ($R);    }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.