<?php
//Include Config file for Username and Password
include 'config.php';
// start the session
session_start();
$errorMessage = '';
if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {
// check if the user id and password combination is correct
if ($_POST['txtUserId'] === $username && $_POST['txtPassword'] === $password) {
// the user id and password match,
// set the session
$_SESSION['basic_is_logged_in'] = true;
// after login we move to the main page
header('Location: list.php');
exit;
} else {
$errorMessage = 'Sorry, wrong user id / password';
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>X-Mas Gift Database</title>
<style type="text/css">@import url("style.css");</style>
</head>
<body>
<center><h2>X-Mas Gift Database</h2></center>
<br>
<center><br>
<?php
$filename = 'lib/installdb.php';
if (file_exists($filename)) {
echo "<P><b>Warning!</b> The file '/$filename' exists, please delete it ASAP!<P><br>";
}
?>
<?php
if ($errorMessage != '') {
?>
<p align="center"><strong><font color="white"><?php echo $errorMessage; ?></font></strong></p>
<?php
}
?>
<form method="post" name="frmLogin" id="frmLogin" action="">
<table width="300" border="1" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="150">User Id</td>
<td><input name="txtUserId" type="text" id="txtUserId"></td>
</tr>
<tr>
<td width="150">Password</td>
<td><input name="txtPassword" type="password" id="txtPassword"></td>
</tr>
</table><br>
<input type="submit" class="btn" name="btnLogin" value="Login">
</form>
</center>
</body>
</html>