用php输入类型参数发出POST请求?

时间:2018-08-13 11:50:36

标签: php json

在此代码中,我从另一台服务器获取JSON数据,并使用PHP形式输入该服务器,根据我的输入类型的名称,我创建了一些对象用作参数,以便可以从中获取数据URL并将tham保存到我的数据库中。问题是

   $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>

0 个答案:

没有答案
相关问题