php搜索dir和echo如果存在与否

I have a form with a editbox and a submit button. when someone types something in the editbox, lets say 'hello', the form would then search a directory on the server and echo the result on the page (below the editbox) like this - this directory exists 'or' this directory does not exist

Hope someone can help, any help is very appreciated.

<?php
$dir = 'hello';
if (is_dir($dir)) {
echo "The folder $dir exists";
} else {
echo "The folder $dir does not exist";
}
?>

The above code echo's if the directory 'hello' exists or not, this works fine, I just need it to read from another directory on the server and also from a form, I'm not sure what to place in the 'action' part of the php form for it to recognise and display the query.

Cheers,

If your form does a GET request, you can access the value from the $_GET variable.
If you need to check existence of a folder in another folder, you just need to create a string, that points to that folder.

<form>
    <input name="dir"/><input type="submit"/>
</form>
<?php
    if (isset($_GET['dir'])) // check if value is actually sent
    {
        $dir = $_GET['dir']; // retrieve the value
        if (is_dir('some_folder/'.$dir)) {
            echo "The folder $dir exists";
        } else {
            echo "The folder $dir does not exist";
        }
    }
?>