-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
70 lines (66 loc) · 2.17 KB
/
index.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php require_once('lib/init.php'); ?>
<?php
if(!isset($session)) {
$session = new Session();
$session->message();
}
?>
<?php if($session->isLoggedIn()) { redirect_to("app/index.php"); } ?>
<?php
if(isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
if(empty($username) || empty($password)){
$err = "Username or password cannot be empty";
} else {
$found = User::authenticate($username, $password);
if($found){
$session->login($found,$ac);
$session->message("Welcome {$username}");
$session->sessionVar("user", "You are logged in as {$username}");
redirect_to("app/index.php");
} else {
$err = "Username and/or password is incorrect. Please try again";
}
}
} else {
// Form not submitted
$msg = "";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>App Real Estate</title>
<link rel="stylesheet" href="css/main.css" type="text/css" media="screen" />
</head>
<body style="background:url(images/bkg_15.jpg);">
<div id="login_form">
<h1 style="padding-left:80px;">Real Estate Logix</h1>
<?php
if(!empty($err)) { echo display_error($err); }
$mesg = $session->message();
if(!empty($mesg)) { echo output_message($mesg); }
?>
<h2 style="padding-left:50px;">Sign In to Use Application</h2>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table>
<tr>
<td><label for="username">Username
<span class="requiredField">*</span></td>
<td><input type="text" name="username" id="username" size="40" /></td>
</tr>
<tr>
<td><label for="password">Password
<span class="requiredField">*</span></td>
<td><input type="password" name="password" id="password" size="40" /></td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="submit" value="Login" /></td>
</tr>
</table>
</form>
</div>
</body>
</html>