forked from tylerhall/simple-php-framework
/
login.php
41 lines (37 loc) · 1.75 KB
/
login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?PHP
require 'includes/master.inc.php';
if($Auth->loggedIn()) redirect(WEB_ROOT);
if(!empty($_POST['username']))
{
if($Auth->login($_POST['username'], $_POST['password']))
{
if(isset($_REQUEST['r']) && strlen($_REQUEST['r']) > 0)
redirect($_REQUEST['r']);
else
redirect(WEB_ROOT);
}
else
$Error->add('username', "We're sorry, you have entered an incorrect username and password. Please try again.");
}
// Clean the submitted username before redisplaying it.
$username = isset($_POST['username']) ? htmlspecialchars($_POST['username']) : '';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Sample Login Page</title>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/reset-fonts-grids/reset-fonts-grids.css">
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/base/base-min.css">
</head>
<body>
<form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="post">
<?PHP echo $Error; ?>
<p><label for="username">Username:</label> <input type="text" name="username" value="<?PHP echo $username;?>" id="username" /></p>
<p><label for="password">Password:</label> <input type="password" name="password" value="" id="password" /></p>
<p><input type="submit" name="btnlogin" value="Login" id="btnlogin" /></p>
<input type="hidden" name="r" value="<?PHP echo htmlspecialchars(@$_REQUEST['r']); ?>" id="r">
</form>
</body>
</html>