HTML代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>提交</title>
</head>
<style>
.div1 {
/*调整矩形框的大小、居中、颜色*/
height: 30%;
width: 40%;
margin: auto;
margin-top: 15%;
color: #2ca02c;
text-align: center;
background-color: #76deff;
/*让边框变成圆角*/
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
/*给边框添加阴影样式*/
box-shadow: 2px 4px 6px #000;
}
.div2 {
height: 20%;
border-bottom: 1px solid #1099c5;
font-family: 微软雅黑;
font-size: 20px;
line-height: 40px;
}
.div3 {
margin-top: 20px;
}
/*页面的背景颜色*/
body {
background-color: #c5e1ea;
}
/*“提交”按钮的样式*/
.fill:hover,
.fill:focus {
box-shadow: inset 0 0 0 2em var(--hover);
}
.fill {
--color: #a972cb;
--hover: #cb72aa;
}
button {
color: var(--color);
-webkit-transition: 0.25s;
transition: 0.25s;
}
button:hover, button:focus {
border-color: var(--hover);
color: #fff;
}
button {
background: none;
border: 2px solid;
font: inherit;
line-height: 1;
margin: 0.5em;
padding: 1em 2em;
}
.div33 {
width: 30%;
}
</style>
<body>
<div class="div1">
<div class="div2">
资料提交
</div>
<div class="div3">
<form method="post" action="{:url('tijiao/post')}">
账户:
<input type="text" class="div33" name="account"><br>
<br>
密码:
<input type="password" class="div33" name="password"><br><br><br>
<button class="fill">提交</button>
</div>
</form>
</div>
</body>
</html>
PHP代码
<?php
namespace app\index\controller;
use think\Request;
use think\Controller;
class Tijiao extends Controller
{
public function index()
{
return view();
}
public function post(){
//前端提交上来的数据
$data['account'] = Request::instance()->param('account');
$data['password'] = Request::instance()->param('password');
//存储提交上来的数据
$res = db('dengru')->insert($data);
if($res){
return "提交成功";
}else{
return "提交失败";
}
dump($data);
}
}