HTML and PHP help please
I would write to a text file then watch it.
On the web side of things.
<!doctype html> <head> <title>Example</title> </head> <?php if (isset($_POST['form_submitted'])) { file_put_contents('webInput', $_POST['textInput']."\n", FILE_APPEND); } ?> <body> <form action="index.php" method="POST"> <div> Text Input: <input type="text" name="textInput"> </div> <input type="hidden" name="form_submitted" value="1" /> <input type="submit" value="Submit"> </form> </body> </html>
Then in a terminal, do something like this.
watch -n2 tail -5 /path/to/htdocs/webInput
In this example we are writing to "webInput" then reading last 5 lines every 2 seconds in a terminal.
4 hours ago, SupaKomputa said:I don't think php can directly talk to the console.
You need some kind of listener that reads the output from the log or database.
So the input you type in has to be stored somewhere and then you run a command in the terminal to read it.
You can use exec or passthru, but it opens up a world of security and permission issues, especially when you make it accept outside user input.
These examples probably wont work unless you have setup permissions for it or you have your web server configured incorrectly.
exec("wall ".$_POST['textInput']);
passthru("echo ".$_POST['textInput']." >> /dev/pts/1")
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now