The following thinkphp framework tutorial column will introduce to you how ThinkPHP6 uses form tokens to verify the validity of data sources. I hope it will be helpful to friends in need!
Use form tokens in thinkphp6 to verify data source validity to prevent attacks:
Use
<input type="hidden" name="__token__" value="{:token()}" />
or
{:token_field()}
public function index(Request $request) { $check = $request->checkToken('__token__'); if(false === $check) { // ... } }
$rule = [ 'name' => 'require|max:25|token', 'email' => 'email', ];
Recommended: "The latest 10 thinkphp video tutorials"
The above is the detailed content of How to use form token to verify the validity of data source in ThinkPHP6. For more information, please follow other related articles on the PHP Chinese website!