A form of 2 buttons, PHP background How to determine which button is submitted

Source: Internet
Author: User

Method One:

<Divclass= "Container theme-showcase"role= "Main">    <formclass= "Form-horizontal"Method= "POST"Action= "<?php echo base_url ("manage/audit/user ");?>"><Divclass= "Form-group">            <labelclass= "Col-sm-2 Control-label">User name</label>            <Divclass= "Col-sm-10">                <Pclass= "Form-control-static"><?php echo $user [' user_name '];?></P>            </Div>        </Div>        ................................        <HR>        <Divclass= "Row">            <Divclass= "Col-xs-6"><Buttontype= "Submit"name= "Audit_btn"value= "PASS"class= "btn btn-success pull-right">Audit through</Button></Div>            <Divclass= "Col-xs-6"><Buttontype= "Submit"name= "Audit_btn"value= "NoPass"class= "btn btn-danger pull-left">Audit does not pass</Button></Div>        </Div>        <inputtype= "hidden"name= "user_id"value= "<?php echo $user [' user_id '];?>" />    </form></Div> <!--/container -

 /** * User Audit*/     Public functionAudit_user () {$audit _btn=$this->input->post (' audit_btn ',TRUE); if("PASS" = =$audit _btn) {            //Audit through            $user _audit_status= ' audited '; //Message Content            $msg= ' User certification audit has passed, please click to view the status of certification! ‘; }        if("nopass" = =$audit _btn){            //audit does not pass            $user _audit_status= ' audit_failed '; $msg= ' User authentication audit failed, please click to view the status of certification! ‘; }        $user _id=$this->input->post (' user_id ',TRUE); ..............................    }

Method Two:

You can set the button to a name example:
<input type= "Submit" name= "Submit" value= "Submission"/>
<input type= "Submit" Name= "Submit2" value= "Submit 2" >
If it is a post submission

In PHP, you can use the
<?php
if (!empty ($_post[' submit ')) {
Echo ' Click to submit ';
} elseif (!empty ($_post[' submit2 ')) {
Echo ' Click is submit 2 ';
}
?>

A form of 2 buttons, PHP background How to determine which button is submitted

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.