I'm running apache2 webserver on Ubuntu machine. I want to do something like this example but when the button is pressed instead of displaying the date I want to (for example) to cat some file from the server (like: cat /proc/version).
I did something like this (index.php content):
Code: Select all
echo exec('cat /proc/version');
<form action="index.php" method="post">
<input type="submit" value="go!"/>
1: the above works but is this a correct way to do this kind of stuff? It's like a loop...
2: when I click button "go!" a new page is loaded. How can I avoid this? Is there a way to do this like in the example in w3c above? I mean to have the result displayed on the same page...
3: if I have two files HTML and PHP and the HTML uses form to submit request to the server (PHP part) how to obtain the data from the PHP part in the HTML? In this case the value of "/proc/version"? Something like call PHP function and get the return result in HTML (don't know if I can explain it better...).
Of course I Googled it a bit but can't find what I want
Obviously I'm really not in the web development so excuse my really stupid questions
Pleas explain like I'm an idiot