我正在尝试在php中打印出登录框的值,但值始终显示为空。如果我为echo添加一个显式值,它就可以工作。请有人可以告诉我我可能做错了什么。感谢
<form name="login-form" class="login-form" action="index.php" method="post">
<!--HEADER-->
<div class="header">
<!--TITLE--><h1>Client Portal Login</h1><!--END TITLE-->
<!--DESCRIPTION--><span>Please login to your client portal</span><!--END DESCRIPTION-->
</div>
<!--END HEADER-->
<!--CONTENT-->
<div class="content">
<!--USERNAME--><input name="username" type="text" class="input username" value="Username" onfocus="this.value=''" /><!--END USERNAME-->
<!--PASSWORD--><input name="password" type="password" class="input password" value="Password" onfocus="this.value=''" /><!--END PASSWORD-->
</div>
<!--END CONTENT-->
<!--FOOTER-->
<div class="footer">
<!--LOGIN BUTTON--><input type="submit" name="submit" value="Login" class="button" /><!--END LOGIN BUTTON-->
<!--REGISTER BUTTON--><input type="submit" name="submit" value="Register" class="register" /><!--END REGISTER BUTTON-->
</div>
<!--END FOOTER-->
</form>
<?php
if(isset($_POST['submit'])){
$username=$POST["username"];
$password=$POST["password"];
echo $username . " " . $password;
}
?>
答案 0 :(得分:0)
http://www.php.net//manual/en/reserved.variables.post.php
编辑:另外,请考虑清理$ _POST数据:
Do htmlspecialchars and mysql_real_escape_string keep my PHP code safe from injection?