<?php
session_start(); //initiates the sessions
if ($_POST[’submit’])//checks to make sure the login form has been submitted
{
$pass = "YOUR PASSWORD HERE";
$user = "YOUR USERNAME HERE";
if ($_POST[‘pass’] == $pass && $_POST[‘user’] == $user)//checks if the password submitted by the user matches the password stored in the $pass variable
{
$_SESSION[‘access’] = 1;//if login is successful create a session that can be authenticated
header("Location: " . $_SERVER[‘PHP_SELF’]);//reload the page. The page will now not load the login form (see the first if condition)
}
else// if password is incorrect reload the login form
{
header("Location: " . $_SERVER[‘PHP_SELF’]);
}
}
else if (!$_SESSION[‘access’])//if the "access" session is not accessible show the form (not logged in)
{?>
<form action="<?php echo $_SERVER[’PHP_SELF’]; ?>" method="post">
<table align="center" cellpadding="3" cellspacing="3">
<tr>
<td bgcolor="#F7F7F7">Username:</td>
<td bgcolor="#F7F7F7"> <input name="user" type="text" /></td>
</tr>
<tr>
<td bgcolor="#F7F7F7">Password</td>
<td bgcolor="#F7F7F7"><input name="pass" type="text" /></td>
</tr>
<tr>
<td colspan="2" bgcolor="#F7F7F7"><div align="center">
<input name="submit" type="submit" value="Login">
</div></td>
</tr>
</table>
</form>
<?php
exit;
}
?>