
PHP表单无法获取值
我写了管理员登录页面,希望通过输入用户名和密码点击“提交”按钮后,在本页面显示刚才输入的管理员名和密码。下面是代码,不知道哪里出错了,根本无法获取到提交的内容。帮帮忙~<...
我写了管理员登录页面,希望通过输入用户名和密码点击“提交”按钮后,在本页面显示刚才输入的管理员名和密码。下面是代码,不知道哪里出错了,根本无法获取到提交的内容。帮帮忙~
<table width="33%" border="0">
<tr>
<td height="55" align="left" valign="top"><table width="100%" border="0">
<tr>
<td width="38%" height="31" align="center">管理员:</td>
<td width="62%"><form action="index.php" method="post" name="username" >
<label>
<input name="username" type="text" id="username" value="" size="20">
</label>
</form>
</td>
</tr>
<tr>
<td height="27" align="center">密码:</td>
<td><form action="http:127.0.0.1:8081/index.php" method="post" name="password" id="password">
<label>
<input name="password" type="password" id="password" value="" size="20">
</label>
</form>
</td>
</tr>
<tr>
<td height="27"> </td>
<td align="center"><form>
<label>
<input type="submit" name="Submit" value="提交">
</label>
</form>
</td>
</tr>
</table></td>
</tr>
<tr>
<td height="25" align="center">管理员:mr</td>
</tr>
<tr>
<td height="27" align="center">密码:mrsoft</td>
</tr>
</table>
<?php
if($Submit=="提交"){
$username=$_POST[username];
$password=$_POST[password];
}
?>
<?php echo "管理员:$username" ?>
<?php echo "密码:$password" ?> 展开
<table width="33%" border="0">
<tr>
<td height="55" align="left" valign="top"><table width="100%" border="0">
<tr>
<td width="38%" height="31" align="center">管理员:</td>
<td width="62%"><form action="index.php" method="post" name="username" >
<label>
<input name="username" type="text" id="username" value="" size="20">
</label>
</form>
</td>
</tr>
<tr>
<td height="27" align="center">密码:</td>
<td><form action="http:127.0.0.1:8081/index.php" method="post" name="password" id="password">
<label>
<input name="password" type="password" id="password" value="" size="20">
</label>
</form>
</td>
</tr>
<tr>
<td height="27"> </td>
<td align="center"><form>
<label>
<input type="submit" name="Submit" value="提交">
</label>
</form>
</td>
</tr>
</table></td>
</tr>
<tr>
<td height="25" align="center">管理员:mr</td>
</tr>
<tr>
<td height="27" align="center">密码:mrsoft</td>
</tr>
</table>
<?php
if($Submit=="提交"){
$username=$_POST[username];
$password=$_POST[password];
}
?>
<?php echo "管理员:$username" ?>
<?php echo "密码:$password" ?> 展开
展开全部
代码写的太乱了,一个表单就可以了,
if($Submit=="提交"){}改为if($_POST['Submit']=="提交"){},$username=$_POST[username];
$password=$_POST[password];
应为$username=$_POST['username'];
$password=$_POST['password'];
if($Submit=="提交"){}改为if($_POST['Submit']=="提交"){},$username=$_POST[username];
$password=$_POST[password];
应为$username=$_POST['username'];
$password=$_POST['password'];
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
if($Submit=="提交"){}改为if($_POST['Submit']=="提交"){}先从post获得数据吧……
建议先看看书
建议先看看书
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
if($Submit=="提交")这个错了
你改为if($_POST['Submit']=="提交")
你改为if($_POST['Submit']=="提交")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
建议你把东西放到一个表单里面
然后 action
然后 action
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询