I am trying to send data to an external API, the problem is that when I open the console in chrome or inspect any element, it shows the hidden
form values that are the API keys, so try this with Curl
:
<?php
$ch = curl_init('https://apiurl.com/');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "ApiKey=$ak&merchantId=$mi&accountId=$ac");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,false);
$respuesta = curl_exec ($ch);
curl_close ($ch);
?>
Now, I have 3 questions:
- I understand that this function is done automatically, so how do I do it with a
<input type="submit">
or a<button>
? - Is it safe to send data this way?
- What other way to send this data do you suggest?