<html>
<head>
<title>Login</title>
<link href="styles_validate.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
session_start();
$postback = $_POST['postback'];
if ($_POST['password'] == 'guest' && strlen($_POST['username']) > 0) //correct inputs
{
$_SESSION['firstName']=$_POST['username'];
header("location: index.php");
}
?>
<div class="pageContainer">
<h2>Login</h2><hr>
<form method="post">
Please enter your first name:<br>
<input type="text" name="username" value="<?php echo $name; ?>" size="25"><br>
<?php
if ($_POST['postback'] && (strlen($_POST['username']) < 1 ))//incorrect name
{
echo "<font color='red'>Please enter your name.</font>";
$pagevalid = false;
}
?>
<br><br>
Please enter your password:<br>
<input type="password" name="password" size="25"><br>
(Password is "guest")<br>
<?php
if ($_POST['password'] != 'guest' && $postback)//incorrect pwd
{
echo "<font color='red'>Please enter the password 'guest'.</font>";
}
?>
<br><br>
<input type="submit" value="Login"><br>
<input type="hidden" name="postback" value="true">
</form>
<a href="index.php">Try going to index.php without logging on.</a>
</div>
</body>
</html>
and I get the errors as follows:
Notice: Undefined index: postback in C:\xampp\htdocs\Site1\login.php on line 12
Notice: Undefined index: password in C:\xampp\htdocs\Site1\login.php on line 14
br /><b>Notice</b>: Undefined variable: name in <b>C:\xampp\htdocs\Site1\login.php</b> on line <b>25</b><br />
Notice: Undefined index: postback in C:\xampp\htdocs\Site1\login.php on line 27
Notice: Undefined index: password in C:\xampp\htdocs\Site1\login.php on line 39