So I have this code
<?php
if (isset($_POST['submit_var']))
{
$formvalue = $_POST['input_value'];
exec('sudo python LCD_Log_Write.py ' .$formvalue);
}
?>
<form action="?submit =true" method="POST">
<input type="text" name="input_value">
<input type="submit" name="submit_var">
which is a text box and a submit button, when the button is pressed the text in the text box shows up on an LCD connected to my Raspberry Pi. My question is how do I automate filling in this text box and clicking this button with Tasker? If you're not familiar with Tasker it can use HHTP gets, posts and Heads so if you know how to do it with that you would also be a huge help to me! Thank you!
You could achieve what you need by using Web interface and automating input / clicking, but that would be very inefficient. Best approach is, indeed, using http post.
Assuming that the code is run when IP 1.2.3.4 is used, you'd create a http post
task and you fill it in like that:
server:port
1.2.3.4
path
/index.php (if that's the file you're using)
data / file
input_value=%txt_var
submit_var=true
content-type
x-www-form-urlencoded
If it still doesn't work, leave content-type
empty.
And that should do.
Please note the new line in data / file
field.
Also, the %txt_var is a tasker variable to be filled in prior to sending the http post request
Since you'd have it done this way you could alter your php code, leaving only first 7 lines (as the rest would not be needed) or go even further and leave only line 4 and 5
Alternatively, if the if
is required, change it to check whether input_value
is set and not empty