Using HTML with PHP and shell exec to search for files

I am a complete beginner in PHP.
I am trying to create a HTML/ PHP Script that will use the user input from an HTML form and than use php shell_exec to search for files with that input using the “find /var/www -Name ” command.

I know how ro run a simple script with PHP, but I have no idea how do do that with user Input…
Eg: “

<?php
    if (isset($_POST['button']))
    {
         exec('test.sh');
    }
?>
<html>
<body>
    <form method="post">
    <p>
        <button name="button">Run Script</button>
    </p>
    </form>
</body>

This is how far I’ve got. I’ve decided two make to files, one HTML, the second one the PHP script:

search.html

<html> 
<body>
<form action="search.php" method="post">
keyword: <input type="text" name="keyword"><br>
<input type="submit">
</form>
</body>
</html>

php script:
search.php

    <html>
<body>

<?php shell_exec('find /var/www -Name "keyword"') $_POST["keyword"]; ?>
</body>
</html>


Source: forms

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.