-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserLogin.php
118 lines (109 loc) · 2.86 KB
/
UserLogin.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/*
Name: UserLogin.php
Path: Root/project3/login.php
Version: 1
Function: This page serves as the login page for the user. It contains all messages that pertain to the credentials including success, server failure, and incorrect credentials. Additionally,
the admin credentials are located on this page.
*/
@SESSION_START();
//check to make sure the fields are not left blank, validate them
if(isset($_POST['submit'])){
require('automate/login.php');
}
@session_start();
//echo "<p>".$_SESSION['username']."</p>";
//echo "<p>".$_SESSION['loginstatus']."</p>";
//echo "<p>".$_SESSION['privilege']"</p>";
?>
<html>
<!--
Name: UserLogin.php
Path: Root/project3/UserLogin.php
Version: 1
Function : This page will verify user credentials. If it doesn't receive the correct
credentials, the user will be redirected back to this page and an error message will be
displayed.
-->
<head>
<title>Login</title>
<link rel='stylesheet' href='HomePage.css'>
<style>
#error{
color: red;
left-margin: 3em;
font-weight: bold;
text-align: center;
font-size: 1.25em;
}
#login_button{
margin-left: auto;
margin-right: auto;
color: white;
background: black;
border: 2px solid blue;
padding: 1em;
}
#buttongroup{
margin-left: auto;
margin-right: auto;
width: 20%;
}
label{
margin-left: 1em;
}
input{
margin-top: 1em;
}
h1{
width: 30%;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<?php
include("automate/header.php");
?>
<?php
@SESSION_START();
//isset($_SESSION['privilege']) ? $sess = $_SESSION['privilege'] : $sess = "NotSet";
if(@$_SESSION['loginstatus'] == "IN"){
print "<h1>Login was successful!</h1>
<h2>Welcome ".$_SESSION['username']."!</h2>
<br><br><br>";
($_SESSION['privilege'] == "COMM") ? print "<a href='Products.php'>Go to products</a>" : print "<a href='automate/allusers.php'>View All Users</a>";
}
?>
<form id='loginform' name='loginform' action='<?php $_SERVER['PHP_SELF'] ?>' method='post'>
<?php
@SESSION_START();
if(@$_SESSION['loginstatus'] !== "IN"){
print "<h1>Login to continue</h1>
<div id='buttongroup'>
<br><br>
<input type='text' id='username' name='username'><label>Username</label>
<br>
<input type='password' id='password' name='password'><label>Password</label>
<br><br><br>
<input type='submit' value='Login' id='login_button' name='submit'>
<p>Not a member? <a href='UserRegistration.php'>Register here</a></p>
</div>";
}
?>
</form>
<?php
@SESSION_START();
if(@$_SESSION['loginstatus'] == "PROBLEM"){
echo "<br><br><p id='error'>Your user name or password is incorrect! Try Again!</p>";
}
if(@$_SESSION['loginstatus'] == "SERVER_ERROR"){
echo "<p id='error'>The site will be unavailable due to maintenance. Please try back again shortly. </p>";
}
?>
<?php
include("automate/footer.php");
?>
</body>
</html>