I have a webpage provided by the server. I have about 20 different clients accessing this webpage. The webpage is a simple form with a textbox displaying to each client. Client is responsible for providing the input usually it would be through input device like a keyboard, microphone, barcode scanner etc. I have a different device which cannot directly input its value to the textbox but only through a variable value. Server is using WAMP and each client has LAMP installed on it.
I created a request for that input from the server using ajax call but that is not ideal and I do not want to put too much pressure onto the server. I just want the variable to be sent automatically to the webpage as it is being loaded by the client. I heard it can be done using cURL, but my question is what would be the best way to achieve this and how to do it? Would it be easier to send a variable from a shell to a web browser on the load? I’m looking for a secure but easy to implement method. This is what my attempt was: (although I got confused on how to approach this)
Server: (WAMP Server / server.php)
<?php
if(isset($POST)){
$_POST['var'];
}
?>
<html>
<body>
<form action="" method="post">
<input type="text" name='var' value="<?php echo "$var"; ?>"/>
</form>
</body>
</html>
Client: (LAMP Server / inputProv.php)
<?php
$var = "Hello";
echo $var;
?>
Client: (LAMP Server / send.php)
<script>
$(document).ready(function(){
$.get("http://localhost/inputProv.php", function(response) {
$("input[name=var]").val(response):
});
});
</script>