代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>MAC search</title>
</head>
<body align="middle" bgcolor="gray">
<h1><font size="20" face="Verdana" color="blue">MAC search</font></h1>
<form action="" method="post">
MAC:
<input type="text" name="mac" size="20"/>
<input type="submit" value="submit"/>
</form>
<?php
if(isset($_POST[‘mac‘])&&$_POST[‘mac‘]!=‘‘){
$mac=$_POST[‘mac‘];
$output = shell_exec("macsearch $mac");
echo "$output";
}
?>
</body>
</html>
分析如下:
1.通过表单传入一个参数“mac”
<form action="" method="post">
MAC:
<input type="text" name="mac" size="20"/>
<input type="submit" value="submit"/>
</form>
2.通过php传入参数并且运行shell脚本
<?php
if(isset($_POST[‘mac‘])&&$_POST[‘mac‘]!=‘‘){
$mac=$_POST[‘mac‘];
$output = shell_exec("macsearch $mac");
echo "$output";
}
?>
原文:http://easyyx.blog.51cto.com/8603153/1733474