«^»
4.3. Including other files and executing OS commands

The next example contains two unrelated topics:

Here is a WWW form that asks a visitor for a command:

0096: <HTML><BODY>
0097: <FORM METHOD="POST" ACTION="system.php">
0098:    <P>
0099:    Enter the command to be executed:<INPUT TYPE="Text" NAME="command">
0100:    <INPUT TYPE="Submit" VALUE="Execute command">
0101: </FORM>
0102: </BODY></HTML>

And here is a PHP script to execute the visitor's OS command:

0103: <HTML><BODY>
0104: <?php
0105:    $command = $_POST["command"];
0106:    require("head.htm");
0107:    if ( $command == "DIR" )
0108:       system("$command");
0109:    else
0110:       echo "<P>not executing: $command</P>";
0111:    require("foot.htm");
0112: ?>
0113: </BODY></HTML>

Go to the WWW form at: http://www.dur.ac.uk/barry.cornelius/papers/phpintro/code/system.htm