Ich bin neu in PHP und ich versuche, eine kleine Anwendung darin zu entwickeln. Hat einen undefinierten Indexfehler erhalten, versucht, den Pfad richtig einzustellen, konnte diesen Fehler jedoch nicht beheben. Es wäre toll, wenn mir jemand helfen könnte, diesen Fehler zu lösen. Bitte finden Sie den Code im Anhang.Undefinierter Index in uname und übergehen in PHP-warum
ERROR: Undefiniert Index: uname in D: \ wamp64 \ www \ BBMS \ loginCheck.php ERROR: Undefiniert Index: upass in D: \ wamp64 \ www \ BBMS \ loginCheck.php auf Leitung 4
1.header.php
<html>
<body>
<frameset cols="20%,*">
<frame name="logo">
<a href="index.html"><img src="images/logo.jpg" width="20%" height="30%"/></a>
</frame>
<frame name="login">
<?php include('login.php');?>
</frame>
</body>
</html>
2.login.php
<html>
<head>
<script type="text/javascript" language="JavaScript">
function validate()
{
if(document.getElementByName("uname").value==""||document.getElementByName("upass").value=="")
{
document.getElementById("msg").innerHtml="Donor Login and password must not be left empty";
document.getElementByName("uname").focus();
document.getElementByName("upass").focus();
}
else
{
<?php header('Location:loginCheck.php');?>
}
}
</script>
<?php
if (isset($_GET['msg'])) {
$msg=$_GET['msg'];
}
else
$msg="";
?>
</head>
<body>
<p id="msg"><?php echo $msg;?></p>
<form method="post">
Donor Login<input type="text" name="uname" value="Enter your login id"><br>
Password<input type="password" name="upass" value="Enter the password"><br>
<a href="forgotPassword.php">Forgot Password?</a><br>
<input type="submit" value="Login" onClick="validate()"/>
</form>
</body>
</html>
3.loginCheck.php
<?php
$uname=$_REQUEST["uname"];
$upass=$_REQUEST["upass"];
if($uname==""||$upass=="")
{
//echo "Must not be empty";
header('Location:header.php?msg=Donor Login and password must not be left empty');
}
else if($uname=="admin"&&$upass=="admin")
{
session_start();
echo "Welcome user";
}
else
{
header('Location:login.php?msg=Invalid Login');
}
?>
Mögliche Duplikat [PHP: "Hinweis: Nicht definierte Variable", "Notice: Undefined index" und "Hinweis: Undefined offset"] (http://stackoverflow.com/questions/4261133/php-notice -undefined-variable-notice-undefined-index-und-notice-undef) –