  
namespace App\Http\Controllers;
use IlluminateHttpRequest;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class StudInsertController extends Controller {
public function insertform(){
return view('stud_create');
}
public function insert(Request $request){
$name = $request->input('stud_name');
DB::insert('insert into student (name,age) values(?,?)',[$name, $age]);
echo "Record inserted successfully.<br/>";
echo '<a href = "/insert">Click Here</a> to go back.';
}
}
<html>
<head>
<title>添加 - 学生管理</title>
</head>
<body>
<form action = "/create" method = "post">
<input type = "hidden" name = "_token" value = "<?php echo csrf_token(); ?>">
<table>
<tr>
<td>名字:</td>
<td><input type='text' name='stud_name' /></td>
</tr>
<tr>
<td>密码:</td>
<td><input type='text' email='stud_password' /></td>
</tr>
<tr>
<td>邮箱:</td>
<td><input type='text' email='stud_email' /></td>
</tr>
</table>
</form>
</body>
</html>
|