PHP Review Kathleen Luo
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
<title>应用 list()函数遍历数组</title>
</head>
<body>
<form name="form1" method="post">
<table width="323" border="1" cellpadding="1"
cellspacing="1"
bordercolor="#66CC33"
bgcolor="#FFFFFF">
<tr>
<td width="118" height="24" align="right"
bgcolor="#CCFF33">用户名:</td>
<td width="192" height="24"
bgcolor="#CCFF33"><input name="user" type="text"
class="inputcss" id="user" size="24"></td>
</tr>
<tr>
<td height="24" align="right"
bgcolor="#CCFF33">密 码:</td>
<td height="24" bgcolor="#CCFF33"><input
name="pwd" type="password" class="inputcss"
id="pwd" size="24"></td>
</tr>
<tr align="center" bgcolor="#CCFF33">
<td height="24" colspan="2"><input
name="submit" type="submit" value="登录"></td>
</tr>
</table>
</form>
<?php
//输出用户登录信息
while(list($name,$value)=each($_POST)){
if($name!="submit"){
echo "$name=$value<br>";
}
}
?>
</body>
</html>
“
”
输出结果:在单击 登录 后,在注册表单下面显
示输入的用户名和密码的内容。例如:
用户名:纯净水
密码:123456789
6.
7.
获取表单数据的两种方法:中书 p152
POST 方法:不依赖于 URL,不会显示在地址栏 。
POST 方法可以没有限制地传递数据到服务器,
所有提交的信息在后台传输,用户在浏览器看不
到这一过程,安全性高,适合发送保密或者容量
大的数据。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
<title>使用 POST 方法提交表单</title>
</head>
<body>
<form
name="form1"
method="post"
action="index.php">
<table width="300" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td height="30"> 订单号:
<input type="text" name="user" size="20" >
<input type="submit" name="submit" value=" 提
交"></td>
</tr>
</table>
</form>
</body>
</html>
GET 方法:<form>表单中 method 属性的默认方
法。提交的表单数据被附加到 URL 上,并作为
URL 的一部分发送到服务器端,在 URL 的地址
“
栏中将会显示 URL+
”
用户传递的参数 。格式如下:
http://url?name1=value1&name2=value2......
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
2