请我将我的html表单连接到php脚本表单付款处理,但是我不知道如何构建它。 我希望php在单击“提交”按钮时开始处理付款 这是示例代码
sample payload
{
"price": 1,
"network": "mtn",
"recipient_number": "026xxxxxxx",
"sender": "024xxxxxxx",
"option": "rmta",
"apikey": "",
"orderID": ""
}
sample request
<?php
$url = 'https://client.teamcyst.com/api_call.php';
$additional_headers = array(
'Content-Type: application/json'
);
$data = array(
"price"=> 1,
"network"=> "mtn",
"recipient_number"=> "026xxxxxxx",
"sender"=> "024xxxxxxx",
"option"=> "rmta",
"apikey"=> ""
);
$data = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // $data is the request payload in JSON format
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $additional_headers);
$server_output = curl_exec ($ch);
?>
sample response
{"code":1,"status":"success","id":"XXXXX"}
答案 0 :(得分:0)
您只需使用输入类型“提交”按钮制作表格,然后再提交表格 您可以使用如下所示访问表单数据
if(isset($_POST['button_name']))
{
// access all form field data here
}