【发布时间】:2015-06-25 08:45:22
【问题描述】:
我是 PHP 的完全初学者。 我正在尝试创建一个 HTML/PHP 脚本,它将使用来自 HTML 表单的用户输入,而不是使用 php shell_exec 使用“find /var/www -Name”命令搜索具有该输入的文件。
我知道如何使用 PHP 运行一个简单的脚本,但我不知道如何使用用户输入来执行此操作... 例如:“
<?php
if (isset($_POST['button']))
{
exec('test.sh');
}
?>
<html>
<body>
<form method="post">
<p>
<button name="button">Run Script</button>
</p>
</form>
</body>
"
这就是我已经走了多远。我决定了两个文件,一个是 HTML,第二个是 PHP 脚本:
搜索.html
<html>
<body>
<form action="search.php" method="post">
keyword: <input type="text" name="keyword"><br>
<input type="submit">
</form>
</body>
</html>
php 脚本: 搜索.php
<html>
<body>
<?php shell_exec('find /var/www -Name "keyword"') $_POST["keyword"]; ?>
</body>
</html>
【问题讨论】:
标签: php html forms shell-exec