Yes there are few ways to do it. First check out the CURL Methods Posted here. http://hayageek.com/php-curl-post-get/
You will then have to Create a Script using Ajax or jQuery for button onClick, I will post two examples for jQuery and Javascript below.
jQuery with PHP
1) First save this as your HTML file
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$("#name").click(function(event){
$.post("jQueryPost.php",
{name: "Miguel", surename: "Makonnen"},
function(data) {
$('#result').html(data);}
);
});
});
</script>
<div id="result">
</div>
<input type="button" id="name" value="Check Name" />
2) Then save this as your remote PHP file and name it jQueryPost.php
<?php
if($_POST["name"]) {
$NAME = $_POST['name'];
$SURENAME = $_POST['surename'];
echo "Name ".$NAME."<BR>";
echo "Surname: ".$SURENAME."<BR>";
}
?>
Using "onClick" the script above will send a POST request with a Name + Surename to the Remote PHP file. The Remote PHP file will process the Request and send it as a Callback to your HTML File. You can change content of the PHP to anything you want.
Javascript AJAX with PHP
1) First this as your HTML File.
<script type="text/javascript">
function XmlHttp_Request() {
var xmlHttp = null;
if(window.XMLHttpRequest) { // Firefox, IE7+, Opera Support
xmlHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject) { // fInternet Explorer 5, 6 Support
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlHttp;
}
// Post Ajax Data
function ajaxPost(Filename, Finalise) {
var request = XmlHttp_Request();
// Post Parameters
var postData = 'name='+document.getElementById('myname').innerHTML;
request.open("POST", Filename, true); // Our Post tRequest
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.send(postData); // Post Data
// Check request status
request.onreadystatechange = function() {
if (request.readyState == 4) {
document.getElementById(Finalise).innerHTML = request.responseText;
}
}
}
</script>
<button onclick="ajaxPost('ajaxPost.php', 'finalise')">Check Name</button>
<div id="myname"></div>
<div id="finalise"></div>
2) Then save this as as your remote PHP file named ajaxPost.php.
<?php
if (isset($_POST['name'])) {
echo "Name: Miguel <BR>";
echo "Surname: Makonnen";
}
?>
This will simply send a Response based on Ajax Request with a Name + Surname from the remote PHP file on Button Click. Like I've mentiond, you can change the content of the PHP with a Curl script. It shouldnt be that hard. Good luck