无法得到post过来的值

Legend1988 2012-03-28 05:23:29
<form method="post" action="http://localhost/secret.php" >
<table border="1">
<tr>
<th>Username</th>
<td><input type="text" /></td>
</tr>
<tr>
<th>Password</th>
<td><input type="text" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Log In" /></td>
</tr>
</table>
</form>
初学php,为什么上面无法把name和password传到secret.php里,导致每次都输出Please input an effective username and password?
//secret.php
<?php
//Create short names for variables
if($_POST['name']==''&&$_POST['password']=='')
{
//Visitor need to enter a name and password
echo '<h1>Please input an effective username and password</h1>';
}
elseif($_POST['name']=='root'&&$_POST['password']=='123')
{
echo '<h1>Welcome to the New World!</h1>';
}
else
{
echo '<h1>You are not welcome!</h1>';
}
?>
...全文
127 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
改一下昵称 2012-03-28
  • 打赏
  • 举报
回复
需要为input控件增加name属性,只有这样,浏览器才会把值提交到服务器
<th>Username</th>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<th>Password</th>
<td><input type="text" name="password" /></td>

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧