-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
131 lines (92 loc) · 2.59 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
<?php
session_start();
ob_start();
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Login Form | </title>
<link rel="stylesheet" href="cstyle.css">
</head>
<body>
<?php
include 'dbcon.php';
if(isset($_POST['submit']))
{
$email = $_POST['email'];
$password = $_POST['password'];
$email_search = "SELECT * FROM `register` WHERE email='$email' ";
$query = mysqli_query($con,$email_search);
$email_count = mysqli_num_rows($query);
if($email_count)
{
$email_pass = mysqli_fetch_assoc($query);
$db_pass = $email_pass['password'];
$_SESSION['name'] = $email_pass['name'];
if($db_pass === $password)
{
echo "Login Successfull";
if(isset($_POST['rememberme'])){
setcookie('emailcookie',$email,time()+86400);
setcookie('passwordcookie',$password,time()+86400);
?>
<script>
location.replace("homepage.php");
</script>
<?php
}
else{
?>
<script>
location.replace("homepage.php");
</script>
<?php
}
?>
<script>
location.replace("homepage.php");
</script>
<?php
}
else{
?>
<script>
alert('Password Incorrect');
</script>
<?php
}
}
else{
?>
<script>
alert('Invalid email');
</script>
<?php
}
}
?>
<div class="center">
<h1>Login</h1>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST">
<div class="txt_field">
<input type="text" name="email" value="<?php if(isset($_COOKIE['emailcookie'])) { echo $_COOKIE['emailcookie']; } ?>" required>
<span></span>
<label>Email</label>
</div>
<div class="txt_field">
<input type="password" name="password" value="<?php if(isset($_COOKIE['passwordcookie'])) { echo $_COOKIE['passwordcookie']; } ?>" required>
<span></span>
<label>Password</label>
</div>
<div class="signup_link">
<input type="checkbox" name="rememberme">Remember me
</div>
<input type="submit" name="submit" value="Login">
<div class="signup_link">
Not a member? <a href="register.php"> Register </a>
</div>
</form>
</div>
</body>
</html>