以下是一个示例代码,可以根据需要进行修改:

<!DOCTYPE html>
<html>
<head>
	<title>提交数字页面</title>
</head>
<body>
	<form method="post" action="">
		<label>请输入数字:</label>
		<input type="text" name="number">
		<br><br>
		<label>请输入接口链接:</label>
		<input type="text" name="api_url">
		<br><br>
		<input type="submit" value="提交">
	</form>

	<?php
		if(isset($_POST['number']) && isset($_POST['api_url'])) {
			$number = $_POST['number'];
			$api_url = $_POST['api_url'];

			// 构造请求参数
			$data = array('number' => $number);

			// 发送POST请求
			$options = array(
			    'http' => array(
			        'method' => 'POST',
			        'header' => 'Content-type:application/x-www-form-urlencoded',
			        'content' => http_build_query($data),
			    ),
			);
			$context = stream_context_create($options);
			$result = file_get_contents($api_url, false, $context);

			// 输出结果
			echo "<p>接口返回结果:</p>";
			echo "<pre>" . $result . "</pre>";
		}
	?>
</body>
</html>

使用方法:

  1. 将上述代码保存为一个名为“submit_number.php”的文件,并上传到服务器上。

  2. 在浏览器中访问该文件,即可看到一个输入数字和接口链接的表单。

  3. 输入数字和接口链接后,点击提交按钮,即可自动访问指定的接口,并显示接口返回的结果。

用php写一个提交数字页面 可以设置链接 点击提交后自动访问某接口

原文地址: https://www.cveoy.top/t/topic/YJS 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录