I am new to PHP and i am trying to develop a small application in it. Received an undefined index error, tried to set the path right however could not overcome this error. It would be great if someone could help me solve this error. Please find the code attached below.
ERROR:Undefined index: uname in D:\wamp64\www\bbms\loginCheck.php ERROR:Undefined index: upass in D:\wamp64\www\bbms\loginCheck.php on line 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');
}
?>