I'm trying to set up a webpage with Jquery that will receive button clicks from the user, pass those click values to a PHP script, that will then publish them to a MQTT broker. My connection to the broker seems to be working. I'm having problems passing variables from JavaScript to PHP. What am I doing wrong?
Here's my JavaScript:
<script>
$(document).ready(function(){
$("#button01").click(function(){$.post("post.php", {testvalue:test01});});
});
</script>
and here is my PHP:
<?php
require("../phpMQTT.php");
$testvalue = $_POST['testvalue'];
$mqtt = new phpMQTT("192.168.1.20", 8000, "client");
if ($mqtt->connect()) {
$mqtt->publish("hello/world","$testvalue",0);
$mqtt->close();
}
?>