使用php输入类型参数发出POST请求?
在这段代码中,我从另一台服务器获取JSON数据,并使用PHP表单进入该服务器,根据输入类型的名称,我创建了一些用作参数的对象,以便从URL获取数据并将tham保存到数据库中。问题是使用php输入类型参数发出POST请求?,php,json,Php,Json,在这段代码中,我从另一台服务器获取JSON数据,并使用PHP表单进入该服务器,根据输入类型的名称,我创建了一些用作参数的对象,以便从URL获取数据并将tham保存到数据库中。问题是 $token = stripslashes($_REQUEST["token"]); 它不起作用。我知道我的问题不清楚,但我只是不知道如何问。我做了研究,但我没有找到我想要的。我希望你能帮助我。如果你有任何问题,请问,我会尽力解释 <html> <head> <met
$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>
这可能不起作用,因为在您的第一次mysqli\u查询
调用中,您没有结束的“
并且您没有任何要插入的值。第二次mysqli\u查询
调用也是如此。我只是没有编写完整的代码。问题是:基于我的输入类型,我希望在$data=json\u encode(数组)中保持相同('token'=>$token,代码的一部分从另一台服务器获取JSON数据并将tham保存到我的数据库中,然后是刚刚发送到服务器的输入类型表单。现在,我希望在php表单上输入的所有内容与$data=JSON\u encode(array('token'=>$token)中的参数相同只是,$token
不匹配?你能举一个不匹配的令牌的例子吗?我用了$token=stripslashes($_REQUEST[“token”]);