CODE
<?php
session_start();
echo '<div id="form">'."\n";
if (isset($_POST['submit'])) {
$correct_password = "";
$admin = "";
if (empty($_POST['username'])) {
$errors[] = "You did not enter your username.<br />";
}
if (empty($_POST['password'])) {
$errors[] = "You did not enter your password.<br />";
}
if ($_POST['username'] !== $admin) {
$errors[] = "This username does not exist.<br />";
}
if ($_POST['password'] !== $correct_password) {
$errors[] = "You have entered an incorrect password.<br />";
}
if (count($errors) == 0) {
$_SESSION['admin'] = $_POST['username'];
echo '<script>location.href="admin.php";</script>';
}else{
echo('<div id="errors">'.$errors[0].' <a href="login.php">Return</a></div>');
}
}
echo ' <form action="login.php" method="post">
<label>Username:</label> <input type="username" name="username" class="textbox" /><br />
<label>Password:</label> <input type="password" name="password" class="textbox" /><br />
<div class="buttons"><input type="submit" name="submit" value="Login" /></div>
</form>
</div>'."\n";
?>
session_start();
echo '<div id="form">'."\n";
if (isset($_POST['submit'])) {
$correct_password = "";
$admin = "";
if (empty($_POST['username'])) {
$errors[] = "You did not enter your username.<br />";
}
if (empty($_POST['password'])) {
$errors[] = "You did not enter your password.<br />";
}
if ($_POST['username'] !== $admin) {
$errors[] = "This username does not exist.<br />";
}
if ($_POST['password'] !== $correct_password) {
$errors[] = "You have entered an incorrect password.<br />";
}
if (count($errors) == 0) {
$_SESSION['admin'] = $_POST['username'];
echo '<script>location.href="admin.php";</script>';
}else{
echo('<div id="errors">'.$errors[0].' <a href="login.php">Return</a></div>');
}
}
echo ' <form action="login.php" method="post">
<label>Username:</label> <input type="username" name="username" class="textbox" /><br />
<label>Password:</label> <input type="password" name="password" class="textbox" /><br />
<div class="buttons"><input type="submit" name="submit" value="Login" /></div>
</form>
</div>'."\n";
?>