<!doctype html> <html lang="zh"> <head> <meta charset="utf-8"> <title>自动提交表单模拟发起POST请求</title> </head> <body> <form id="form" action="https://www.example.com/api.php" method="post"> <input type="hidden" name="name" value="张三"> <input type="hidden" name="sex" value="男"> <input type="hidden" name="birth" value="2003"> </form> <script type="text/javascript"> document.getElementById('form').submit(); // 自动提交表单 </script> </body> </html>
<?php // File Name:api.php declare(strict_types=1); ini_set('display_errors', 'On'); ini_set('error_reporting', E_ALL); function_exists('opcache_reset') && opcache_reset(); $name = $_POST['name']; $sex = $_POST['sex']; $birth = $_POST['birth']; echo "俺叫{$name}({$sex}),出生于{$birth}年。";
Copyright © 2024 码农人生. All Rights Reserved