-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
174 lines (133 loc) · 4.09 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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
session_start();
include("connection.php");
include("function.php");
if($_SERVER['REQUEST_METHOD'] == "POST")
{
//SOMETHING WAS POSTED
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$study = $_POST['study'];
$password = $_POST['password'];
if(!empty($firstname) && !empty($lastname) && !empty($study) && !empty($password) && !is_numeric($firstname))
{
//read from from db
$query = "select * from users where firstname = '$firstname' limit 1";
$result = mysqli_query($con, $query);
if($result)
{
if($result && mysqli_num_rows($result) > 0)
{
$user_data = mysqli_fetch_assoc($result);
if($user_data['password'] === $password)
{
$_SESSION['user_id'] = $user_data['user_id'];
header("Location: home.php");
die;
}
}
}
echo "wrong username or password";
}else
{
echo "please provide valid information";
}
}
?>
<!Doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CS60APA Registration-Form</title>
<!--<link rel="stylesheet" href="style.css">-->
</head>
<style>
/* Style the entire page */
* {
box-sizing: border-box;
}
/* Style the form */
form {
width: 400px;
border: 3px solid green;
margin: 0 auto;
}
/* Style the label font weight */
label {
font-weight: bold;
}
/* Adding some padding in form */
.form-container {
padding: 16px;
}
/* Style the img-container */
.img-container {
text-align: center;
margin: 24px 0 12px 0;
}
.img-container img {
width: 40%;
border-radius: 50%;
}
/* Style inputs and textarea */
.form-text {
width: 100%;
padding: 10px 14px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
}
/* change outline when click in inputs and textarea */
.form-text:focus {
outline: 1px solid cadetblue;
}
/* Style the Login button */
.login-btn {
background-color: #04aa6d;
padding: 10px 14px;
color: white;
margin: 8px 0;
border: none;
width: 100%;
cursor: pointer;
}
/* Change background color of submit button when hover */
.login-btn:hover {
opacity: 0.8;
}
/* change the background color of forget container */
.background {
background-color: #f1f1f1;
}
/* style the forget link color */
.forget a {
color: #0088cc;
}
@media only screen and (min-device-width:275px) and (max-device-width:768px) {
form {
width: 100%;
}
}
</style>
<body>
<form action="" method="POST">
<div class="form-container">
<div class="img-container">
<img src="avatar.png" alt="avatar">
</div>
<label for="firstname">FirstName</label>
<input type="text" name="firstname" placeholder="Enter FirstName" class="form-text" required>
<label for="lastname">LastName</label>
<input type="text" name="lastname" placeholder="Enter LastName" class="form-text" required>
<label for="study">Study</label>
<input type="text" name="study" placeholder="Enter your Study Area" class="form-text" required>
<label for="password">Password</label>
<input type="password" name="password" placeholder="Enter Password" class="form-text">
<button type="submit" class="login-btn" value="Login" >Login</button>
</div>
<div class="form-container background">
<span class="forget">Create Account <a href="register.php">Register</a></span>
</div>
</form>
</body>
</html>