代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>build 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>
<input type="submit" value="go" />
</form>');
}
else{
echo "the search string is :<strong>$search</strong>";
}
?>
</body>
</html>
运行的时候不管在表单中输入什么数据都没有返回现实提交的数据,也就是“the search string is : ** ”,还是一个表单。为什么都只是执行if函数而已呢?是不是哪里错了?麻烦各位指教一下小白,最好能自己试一下。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>build 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>
<input type="submit" value="go" />
</form>');
}
else{
echo "the search string is :<strong>$search</strong>";
}
?>
</body>
</html>
运行的时候不管在表单中输入什么数据都没有返回现实提交的数据,也就是“the search string is : ** ”,还是一个表单。为什么都只是执行if函数而已呢?是不是哪里错了?麻烦各位指教一下小白,最好能自己试一下。
还有 get方式取不值记得看你的url
xx.php?get=sss&id=csdn 地址应该是这样的 在等号之前 你的url多了一个加号