comments:
a. PHP is a server side scripting language, this means that you will need to either correctly setup a web-server with PHP installed, or have access to one that has been pre-configured for you. This topic is beyond the scope of this Q/A site.
b. You don't make it clear if you are planing to host the story on the same web-server or If you are planing to allow the end-user to download and play the story on their local machine. If the later then you may need to handle issues like Cross-Origin Resource Sharing, so I would suggest doing the former.
c. You will need to implement a method of uniquely identifying the individual end-users playing your game, this could be as simple as asking them within the game to enter an email address, to as complex as getting them to create an account on your web-site.
d. Harlowe doesn't have a documented Javascript API and the story format has been deliberately designed to restrict access to the internals of it's Javascript engine, because of this it isn't the best choice if you are planing to use Javascript to interact with story variables or the contents of passages.
But to answer you question, I would suggests using the jQuery $.ajax function to communicate between your story and your web-server, using a method similar to how vicgeb did in their Passing Twine variables to PHP question on the Old Forum Archive.
warning: Without further information about the story variables, the structure of your story, and the web-server the following examples need to be generic. Also because I don't know which method you will be using to identify the end-users the following examples will not include any code related to Authentication or Credentials, And finally because I don't have access to a PHP configured web-server the following examples have NOT been tested, (eg. I'm being lazy.)
You would need to implement at least two Javascript functions within your Story Javascript area:
1. A function to send this end-user's data to the relevant PHP file on the web-server.
window.sendOpinionToPoll = function () {
$.ajax({
method : "POST",
url : "receive-opinion-ajax.php",
data : { /* a copy of the relevant story variables goes here! */ }
})
.done(function () {
/* What should happen if the data was sent successfully. */
alert("success");
})
.fail(function () {
/* What should happen if the data transmision failed. */
alert("fail");
});
}
2. A function to retrieve the current Poll result(s) from the relevant PHP file on the web-server.
window.retrievePollResults = function () {
$.ajax({
method : "GET",
url : "retrieve-results-ajax.php",
data : { /* If you want the result for a particular question you would indicate that here! */ }
})
.done(function (data) {
/* What should happen if the data was retrieve successfully. */
alert("success");
})
.fail(function () {
/* What should happen if the retrieval failed. */
alert("fail");
});
}
You could use script elements like those below within your Passages to execute each of the above Javascript functions, exactly where in your Passages you do that depends greatly on how you've implemented your story.
<script>sendOpinionToPoll();</script>
<script>retrievePollResults();</script>