社团活动报名简要代码

简要前端:
<div> <div id="title">社团活动报名系统</div> <div> <form action="{:url('index/baoming')}" METHOD="post" ACCEPT-CHARSET="utf-8"> <table width="20%" border="0" cellpadding="0" cellspacing="2" align='center' valign='middle'> <tr> <td>姓名:</td> <td><input type="text" name="username"></td> </tr> <tr> <td>手机号:</td> <td><input type="text" name="tel"></td> </tr> <tr> <td>邮箱:</td> <td><input type="text" name="email"></td> </tr> <tr> <td>专业:</td> <td><input type="text" name="subject"></td> </tr> <tr> <td>学号:</td> <td><input type="text" name="studentid"></td> </tr> <tr> <td height="26" colspan="2" align="center" valign="middle"><input type="submit" name="tijiao" value="报名" style="width:60px; height:30px" ></td> </tr> </table> </form> <div id="excel"> <a style="text-decoration:none" href="{:url('excel')}" class="btn btn-info radius" id="daochu"><i class="fa fa-search"></i>导出数据</a> </div> </div> </div>

  

    public function baoming()
    {
        $request=request();
        $username = $request->param('username');
        $tel = $request->param('tel');
        $email = $request->param('email');
        $subject = $request->param('subject');
        $studentid = $request->param('studentid');

        $data =[
            'username'=>$username,
            'tel'=>$tel,
            'email'=>$email,
            'subject'=>$subject,
            'studentid'=>$studentid
            ];
        $a = Db::table('user')->insert($data);

        $b = Db::table('user')->getLastInsID();
        if($a){
           $this->success('报名成功,您的识别码为:0000'.$b);
        }
        else{
            echo '输入信息有误';
        }

    }

  

public function excel()
    {
        //导出
        //##########################################################################
        $list = Db::name("user")->select();
        $file_name = date('Y-m-d_His').'.xls';
        $path = dirname(__FILE__);
        Loader::import('PHPExcel.Classes.PHPExcel');
        Loader::import('PHPExcel.Classes.PHPExcel.IOFactory.PHPExcel_IOFactory');

        $PHPExcel = new \PHPExcel();
        // print_r($PHPExcel);die;
        $PHPSheet = $PHPExcel->getActiveSheet();
        $PHPSheet->setTitle("报名信息");
        $PHPSheet->setCellValue("A1","ID");
        $PHPSheet->setCellValue("B1","姓名");
        $PHPSheet->setCellValue("C1","手机号");
        $PHPSheet->setCellValue("D1","邮箱");
        $PHPSheet->setCellValue("E1","专业");
        $PHPSheet->setCellValue("F1","学号");
        $i = 2;
        foreach($list as $key => $value){
            $PHPSheet->setCellValue('A'.$i,''.$value['Id']);
            $PHPSheet->setCellValue('B'.$i,''.$value['username']);
            $PHPSheet->setCellValue('C'.$i,''.$value['tel']);
            $PHPSheet->setCellValue('D'.$i,''.$value['email']);
            $PHPSheet->setCellValue('E'.$i,''.$value['subject']);
            $PHPSheet->setCellValue('F'.$i,''.$value['studentid']);
            $i++;
        }
        $PHPWriter = \PHPExcel_IOFactory::createWriter($PHPExcel,"Excel2007");
        header('Content-Disposition: attachment;filename='.$file_name);
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        $PHPWriter->save("php://output");
    }

  

焚膏油以继晷,恒兀兀以穷年。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值