我尝试了用于登录的简单代码。当我提交详细信息并在屏幕上给出正确的响应时,它工作得很好,但是当我第一次在浏览器中加载它时,它会显示一条错误消息:
Notice: Undefined index: user in C:\wamp\www\test\first.php on line 14
and
Notice: Undefined index: user in C:\wamp\www\test\first.php on line 15
无法确定问题所在。
<html>
<head>
<title>My First PHP Program!</title>
<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<p>username <input type="text" name="usser"/></p>
<p>password <input type="password" name="pass" /></p>
<p> <input type="submit" name="submit" /></p>
</form>
<?php
$name = $_REQUEST['usser'];
$pas=$_REQUEST['pass'];
if($name=="mandeep"&&$pas=="mani"){
echo "successful";
}
else{
echo "Login Failed";
}
?>
</body>
</html>
您必须检查新的表格形式
<?php
if (!empty($_POST)) {
$name = $_REQUEST['usser'];
$pas=$_REQUEST['pass'];
if($name=="mandeep"&&$pas=="mani"){
echo "successful";
}
else{
echo "Login Failed";
} }
?>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句