<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>
<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>
这是一个使用PHP处理HTML表单的示例。当表单为空时,它显示一个包含搜索、最小价格和最大价格字段的表单。如果表单已提交,PHP将显示提交的搜索字符串。
1532

被折叠的 条评论
为什么被折叠?



