方法一:
<div class="container theme-showcase" role="main"> <form class="form-horizontal" method="post" action="<?php echo base_url("manage/audit/user"); ?>" > <div class="form-group"> <label class="col-sm-2 control-label">用户姓名</label> <div class="col-sm-10"> <p class="form-control-static"><?php echo $user['user_name']; ?></p> </div> </div> ................................ <hr> <div class="row"> <div class="col-xs-6"><button type="submit" name="audit_btn" value="PASS" class="btn btn-success pull-right">审核通过</button></div> <div class="col-xs-6"><button type="submit" name="audit_btn" value="NOPASS" class="btn btn-danger pull-left">审核不通过</button></div> </div> <input type="hidden" name="user_id" value="<?php echo $user['user_id']; ?>" /> </form> </div> <!-- /container -->
/** * 用户审核 */ public function audit_user() { $audit_btn = $this->input->post('audit_btn', TRUE); if("PASS" == $audit_btn) { //审核通过 $user_audit_status = 'AUDITED'; //消息内容 $msg = '用户认证审核已通过,请点击查看认证状态!'; } if("NOPASS" == $audit_btn){ //审核不通过 $user_audit_status = 'AUDIT_FAILED'; $msg = '用户认证审核未通过,请点击查看认证状态!'; } $user_id = $this->input->post('user_id', TRUE); .............................. }
方法二:
可以把按钮设置一个名字例:
<input type="submit" name="submit" value="提交" />
<input type="submit" name="submit2" value="提交2">
假如是POST提交
在PHP中可以 用
<?php
if(!empty($_POST['submit'])) {
echo '点击的是 提交 ';
} elseif(!empty($_POST['submit2'])) {
echo '点击的是 提交2 ';
}
?>