帝国cms 二开插件模块设计layui框架php获取复选框和开关值获取。调用layui+php导入数据库并调取参数

php导入数据库代码(文件名:index.php)

$username=$_POST['username'];//标题
$like=implode('|',$_POST['like']);//多选获取值
if($_POST['close']=='on'){$close='on';}else{$close='off';}//获取开关值
$sex=$_POST['sex'];//单选获取值
$empire->query("INSERT INTO `phome_ecms_liuyan` (`username`, `like`, `close`, `sex`) VALUES ('$username', '$like|', '$close', '$sex')");

layui前端代码(index.html)
<form class="layui-form" action="index.php" method="POST" lay-filter="example">
    <div class="layui-form-item">
      <label class="layui-form-label">标题</label>
      <div class="layui-input-inline">
        <input type="text" name="username" lay-verify="required" lay-reqtext="用户名是必填项,岂能为空?" placeholder="请输入" autocomplete="off" class="layui-input">
      </div>
    </div>

	  <div class="layui-form-item">
	    <label class="layui-form-label">复选框</label>
	    <div class="layui-input-block">
	      <input type="checkbox" name="like[]" title="写作" value="写作" checked="">
	      <input type="checkbox" name="like[]" title="阅读" value="阅读">
	      <input type="checkbox" name="like[]" title="发呆" value="发呆">
	    </div>
	  </div>

	  <div class="layui-form-item">
	    <label class="layui-form-label">开关</label>
	    <div class="layui-input-inline">
	      <input type="checkbox" name="close" lay-skin="switch" lay-text="关闭|开启">
	    </div>
	  </div>

	  <div class="layui-form-item">
	    <label class="layui-form-label">单选框</label>
	    <div class="layui-input-inline">
	      <input type="radio" name="sex" value="男" title="男" checked="">
	      <input type="radio" name="sex" value="女" title="女">
	    </div>
	  </div>

	  <div class="layui-form-item">
	    <div class="layui-input-block">
	     <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
	    </div>
	  </div>
	</form>