post传递参数失败问题 本帖最后由 u011432403 于 2014-06-01 23:13:54 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你需要先判断下当前操作,也就是检测是否做提交处理,加上if(isset($_POST['submit'])) admin.php只有3行?报错的可是12行啊。 用你的程序测试了,有些空格并不是空格。修改后如下。<!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>用户登录</title> <style type="text/css"> html{font-size:12px;} fieldset{width:300px; margin: auto;} legend{font-weight:bold; font-size:14px;} .label{float:left; width:55px; margin-left:10px;} .left{margin-left:120px;} .input{width:150px;} span{color: #666666;} </style><script language=JavaScript> <!-- function InputCheck(LoginForm){ if (LoginForm.name.value == "") { alert("请输入用户名!"); LoginForm.name.focus(); return (false); } if (LoginForm.password.value == "") { alert("请输入用户密码!"); LoginForm.password.focus(); return (false); }} //--></script></head><body><div><fieldset><legend>用户登录</legend><form name="LoginForm" method="post" action="admin.php" onSubmit="return InputCheck(this)"><p><label for="name" class="label">用户名:</label><input id="name" name="name" type="text" class="input" /><p/><p><label for="password" class="label">用户密码:</label><input id="password" name="password" type="password" class="input" /><p/><p><input type="submit" name="submit" value=" 确 定 " class="left" /></p></form></fieldset></div></body></html><?php $name = $_POST['name']; $password = $_POST['password']; echo $name,$password;?>测试正常: $name = isset($_POST['name']) ? $_POST['name'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; echo $name,$password; onSubmit="return InputCheck(this)" 去掉试试 安装mysql时mysqladmin password '密码' 命令报错 html如何引用正则表达式? 需要视频教程的新手进 php + mysql + apache 配置 有一段中英文混合的字符串,怎样提取里面的英文单词? 写了文章一个无限分类程序 急需项目经理(有PHP程序经验),月薪4000~6000,大家有兴趣么? 如何用PHP发送电子邮件? 如何实现一个flash按钮具有提交表单的功能 怎样在win2000 专业版上使用PHP 关于php正则匹配的问题 发图文的时候,同时也向推特跟Facebook转发 如何在网站中插入表格 并实现搜索
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户登录</title>
<style type="text/css">
html{font-size:12px;}
fieldset{width:300px; margin: auto;}
legend{font-weight:bold; font-size:14px;}
.label{float:left; width:55px; margin-left:10px;}
.left{margin-left:120px;}
.input{width:150px;}
span{color: #666666;}
</style>
<script language=JavaScript>
<!--
function InputCheck(LoginForm)
{
if (LoginForm.name.value == "")
{
alert("请输入用户名!");
LoginForm.name.focus();
return (false);
}
if (LoginForm.password.value == "")
{
alert("请输入用户密码!");
LoginForm.password.focus();
return (false);
}
}
//-->
</script>
</head>
<body>
<div>
<fieldset>
<legend>用户登录</legend>
<form name="LoginForm" method="post" action="admin.php" onSubmit="return InputCheck(this)">
<p>
<label for="name" class="label">用户名:</label>
<input id="name" name="name" type="text" class="input" />
<p/>
<p>
<label for="password" class="label">用户密码:</label>
<input id="password" name="password" type="password" class="input" />
<p/>
<p>
<input type="submit" name="submit" value=" 确 定 " class="left" />
</p>
</form>
</fieldset>
</div>
</body>
</html><?php
$name = $_POST['name'];
$password = $_POST['password'];
echo $name,$password;
?>
测试正常:
$password = isset($_POST['password']) ? $_POST['password'] : '';
echo $name,$password;