php - 使用 php 输入类型参数发出 POST 请求?
问题描述
在这段代码中,我从另一台服务器获取 JSON 数据,并使用 PHP 表单进入该服务器,根据我的输入类型的名称,我创建了一些用作参数的对象,这样我就可以从 URL 和将它们保存到我的数据库中。问题是
$token = stripslashes($_REQUEST["token"]);
它不起作用。我知道我的问题不清楚,但我只是不知道如何问它我做了我的研究,但我没有找到我想要的我希望你能帮助我。如果你有任何问题,请询问,我会尝试我最好解释一下。
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body >
<?php
require('db.php');
$token = stripslashes($_REQUEST["token"]);
$customerCode = stripslashes($_REQUEST["customerCode"]);
$userName = stripslashes($_REQUEST["userName"]);
$customerID = stripslashes($_REQUEST["customerID"]);
$amount = stripslashes($_REQUEST["amount"]);}
$url = 'xxxx.js';
$data =json_encode(array('token' => $token,
'customerCode' => $customerCode,
'userName' =>$userName,
'customerID' =>$customerID,
'amount' =>$amount)
);
$options = array(
'http' => array(
'header' => "Content-type: application/json\r\n",
'method' => 'POST',
'content' => $data
)
);
$context= stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === TRUE) {
$obj= json_decode($result,true);
mysqli_query($conn,"INSERT INTO deposit
(result, message, dictCount,guID,amount,customerCode,userName,dealerCode)
mysqli_close($conn);
}
else{
$obj= json_decode($result,true);
mysqli_query($conn,"INSERT INTO deposit (result, message) VALUES
mysqli_close($conn);
}
$obj= json_decode($result,true);
var_dump($obj);
?>
<form action = "xxxxxx.js" method = "post" name = "login" >
<input type = "text" name="token" placeholder="token" required />
<input type = "varchar" name="customerCode"placeholder="costumerCode" />
<input type = "varchar" name="userName" placeholder="userName" />
<input type = "int" name="customerID" placeholder="customerID" />
<input type = "int" name="amount" placeholder="amount" required />
<input name="submit" type = "submit" value="Log In"/>
</form>
</body>
</html>
解决方案
推荐阅读
- ios - 如何更改从 CVPixelBuffer 创建的 CGImage 的像素颜色?
- merge - 使用 API 从 Bitbucket 中的 PR 中删除构建
- arrays - 如何查找文档并使用聚合在 mongodb 中查找属性?
- arrays - 在 Angular 中使用 ngValue 选择默认选项
- android - 展开时如何更改展开标题颜色?
- swiftui - 使用带有异步加载行并使用 GeometryReader 布局的 List 时的竞争条件
- javascript - 为什么关于班级的“这个”消失了
- spring-boot - 在弹性搜索或弹簧数据弹性搜索中使用源过滤是否会对性能产生影响?
- android - 在三星设备上运行 AOSP
- javascript - 我正在尝试从 2 个数组中检索结果