作者pael (就是喜欢)
看板PHP
标题[请益] 用 form 传值与 isset 的问题
时间Fri Jun 15 19:43:18 2007
我想请问一下 在 php 中用 form 传变数时是否会有初始值呢?
还是是因为 <input type=text> 之类的标签有初始值
我刚使用 form 传值後再以 isset 去做 if 判断
发现了个怪现象 即使没有输入任何东西在 input box 内
传回的 isset 仍然是"1" 这是正常的吗?
那我该怎麽判断是否有输入资料呢?感激不尽!
测试的程式码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form method="POST" action="test.php">
<table>
<tr><td>帐号:<input type=text name=input></td></tr>
<tr><td><input type=submit value="送出"></td></tr>
</table>
</form>
<?
echo(isset($_POST['input']));
?>
</body>
</html>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.127.144.41
1F:嘘 dinos:isset 是什麽?要不要翻翻使用手册 06/15 19:46
2F:推 LPH66:楼上...@_@ 06/15 20:23
3F:推 buganini:查一下isset对空字串的反应是什麽...建议改用!empty() 06/18 01:40
4F:→ buganini:另外...空字串会不会送出也许还要看client想不想送.. 06/18 01:41