php代码
<?php
namespace app\index\controller;
use think\Request;
class Company
{
public function gongsi()
{
return view();
}
public function post(){
//前端提交上来的数据
$data['name'] = Request::instance()->param('name');
$data['telephone'] = Request::instance()->param('telephone');
$data['address'] = Request::instance()->param('address');
//存储提交上来的数据
$res = db('company ')->insert($data);
if($res){
return "提交成功";
}else{
return "提交失败";
}
dump($data);
}
}
html代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form method="post" action="{:url('company/post')}">
<label>公司名称</label><input type="text" name="name">
<br>
<label>公司电话</label><input type="text" name="telephone">
<br>
<label>公司地址</label><input type="text" name="address">
<br>
<!--<select name="select">-->
<!--<option value ="volvo">Volvo</option>-->
<!--<option value ="saab">Saab</option>-->
<!--<option value ="aa">aa</option>-->
<!--<option value ="ab">ab</option>-->
<!--</select>-->
<input type="submit"value="提交">
</form>
</body>
</html>