PHP处理表单(代码)

来源:互联网 发布:js设置类名 编辑:程序博客网 时间:2024/05/19 17:59
<html>
<head>
<title>Building a form</title>
</head>
<body>
<?php
//取表单值
$search=htmlentities($_GET["search"]);
//取环境变量
$self=htmlentities($_SERVER['PHP_SELF']);
if($search === '') //验证
{
//提交前显示
echo ('
<form action="'.$self.'" method="GET">
<label>Search:<input type="text" name="search" /> </label><br />
<label>Min Price <input type="text" name="min_price" value="0"/></label> <br />
<label>Max Price <input type="text" name="max_price" value="999"/></label> <br />
<input type="submit" value="Go"!>
</form>
');
}
else
{
//提交后处理
echo "The search string is <strong>$search</strong>";
}
?>
</body>
</html>