-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
188 lines (168 loc) · 4.89 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
ob_start();
require_once('./classes/connection.php');
ob_end_flush();
if(isset($_SESSION['USER_ID']) && $_SESSION['USER_ID']!=''){
echo"<script>window.location.href='index.php'</script>";
}else{
}
if(isset($_POST['username']) && $_POST['username']!=''){
$username=mysqli_real_escape_string($con,$_POST['username']);
$password=mysqli_real_escape_string($con,$_POST['pass']);
$res=mysqli_query($con,"SELECT * FROM `users` WHERE `users`.`username`='$username' and `users`.`pass`='$password'");
$check_user=mysqli_num_rows($res);
if($check_user>0){
$row=mysqli_fetch_assoc($res);
$_SESSION['USER_LOGIN']='yes';
$_SESSION['USER_ID']=$row['id'];
$_SESSION['USER_NAME']=$row['username'];
setcookie ("member_login",$row['id'],time()+ (100 * 365 * 24 * 60 * 60));
setcookie ("member_password",$row['pass'],time()+ (100 * 365 * 24 * 60 * 60));
echo"<script>window.location.href='index.php'</script>";
}else{
echo"<script>alert('Invalid credentials')</script>";
echo"<script>window.location.href='login.php'</script>";
}
}else{
echo "hii";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
@import url(https://fonts.googleapis.com/css?family=Roboto:300);
.login-page {
width: 360px;
padding: 8% 0 0;
margin: auto;
}
.form {
position: relative;
z-index: 1;
background: #FFFFFF;
max-width: 360px;
margin: 0 auto 100px;
padding: 45px;
text-align: center;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
}
.form input {
font-family: "Roboto", sans-serif;
outline: 0;
background: #f2f2f2;
width: 100%;
border: 0;
margin: 0 0 15px;
padding: 15px;
box-sizing: border-box;
font-size: 14px;
}
.form button {
font-family: "Roboto", sans-serif;
text-transform: uppercase;
outline: 0;
background: #4CAF50;
width: 100%;
border: 0;
padding: 15px;
color: #FFFFFF;
font-size: 14px;
-webkit-transition: all 0.3 ease;
transition: all 0.3 ease;
cursor: pointer;
}
.form button:hover,
.form button:active,
.form button:focus {
background: #43A047;
}
.form .message {
margin: 15px 0 0;
color: #b3b3b3;
font-size: 12px;
}
.form .message a {
color: #4CAF50;
text-decoration: none;
}
.form .register-form {
display: none;
}
.container {
position: relative;
z-index: 1;
max-width: 300px;
margin: 0 auto;
}
.container:before,
.container:after {
content: "";
display: block;
clear: both;
}
.container .info {
margin: 50px auto;
text-align: center;
}
.container .info h1 {
margin: 0 0 15px;
padding: 0;
font-size: 36px;
font-weight: 300;
color: #1a1a1a;
}
.container .info span {
color: #4d4d4d;
font-size: 12px;
}
.container .info span a {
color: #000000;
text-decoration: none;
}
.container .info span .fa {
color: #EF3B3A;
}
body {
background: #76b852;
/* fallback for old browsers */
background: rgb(141, 194, 111);
background: linear-gradient(90deg, rgba(141, 194, 111, 1) 0%, rgba(118, 184, 82, 1) 50%);
font-family: "Roboto", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
</style>
</head>
<body>
<div class="login-page">
<div class="form">
<form class="register-form" action="login.php" method="POST">
<input type="text" name="username" placeholder="name" />
<input type="password" name="pass" placeholder="password" />
<!-- <input type="text" placeholder="email address" /> -->
<button type="submit">Login</button>
<p class="message">Already registered? <a href="#">Sign In</a></p>
</form>
<form class="login-form" action="login.php" method="POST">
<input type="text" name="username" placeholder="username" />
<input type="password" name="pass" placeholder="password" />
<button type="submit">login</button>
<p class="message">Not registered? <a href="#">Create an account</a></p>
</form>
</div>
</div>
<script>
// $('.message a').click(function() {
// $('form').animate({
// height: "toggle",
// opacity: "toggle"
// }, "slow");
// });
</script>
</body>
</html>