Tp3.2: submission form and operation form; tp3.2: Submission Form

Source: Internet
Author: User

Tp3.2: submission form and operation form; tp3.2: Submission Form

Notes

Create a table first ----

Then, store the entered items in the table:

<Input type = "submit" id = "tijiao" value = "submit"> <form action = "{: U ('validate ')} "method =" post "name =" myform ">

 

Then we will go to the validate method for 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 fails, the verification fails. The error message is not returned. // exit ($ fkyz-> getError ()); ////} else {// other data operations can be performed through verification $ verify = new \ Think \ Verify (); $ yzmyz = $ verify-> check ($ yzm ); if (! $ Yzmyz) {$ this-> error ('verification code error');} else {$ validate = M ("liuyan3"); $ validate-> add ($ date ); $ this-> success ('added successfully ');}}//}

I commented on the verification;

In this way, the input is saved in the data table,

I also need to traverse them in the background, and I will control it;

Convenience:

<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> <a href = "_ CONTROLLER _/xg? Code = {$ v. id} "> <I> </I> edit </a> & nbsp; <a> <I> </I> Delete </a> </td> </tr> </article: list>

Make a change:

Modify the xg method connected to the Controller and pass the id by the way;

Take a look at ajax processing, ajax is 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:address,content:content},                dataType:"TEXT",                type:"POST",                success: function(r)                {                    window.location.href="__CONTROLLER__/index";                }            })        })    }</script></body>

Then the 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);dump($r);    }

Xuan GE's notes @@

 

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.