-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
168 lines (129 loc) · 5.51 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
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
<?php
session_start();
if (isset($_SESSION['SESSION_EMAIL'])) {
header("Location: welcome.php");
die();
}
include 'config.php';
$msg = "";
if (isset($_GET['verification'])) {
if (mysqli_num_rows(mysqli_query($connect, "SELECT * FROM users WHERE code='{$_GET['verification']}'")) > 0) {
$query = mysqli_query($connect, "UPDATE users SET code='' WHERE code='{$_GET['verification']}'");
if ($query) {
$msg = "<div class='alert alert-success'>Account verification has been successfully completed.</div>";
}
} else {
header("Location: index.php");
}
}
if (isset($_POST['submit'])) {
$email = mysqli_real_escape_string($connect, $_POST['email']);
$password = mysqli_real_escape_string($connect, md5($_POST['password']));
$sql = "SELECT * FROM users WHERE email='{$email}' AND password='{$password}'";
$result = mysqli_query($connect, $sql);
if (mysqli_num_rows($result) === 1) {
$row = mysqli_fetch_assoc($result);
if (empty($row['code'])) {
} else {
$otp = rand(100000,999999);
$_SESSION['otp'] = $otp;
$_SESSION['mail'] = $email;
require "Mail/phpmailer/PHPMailerAutoload.php";
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host='smtp.gmail.com';
$mail->Port=587;
$mail->SMTPAuth=true;
$mail->SMTPSecure='tls';
$mail->Username='Your Email';
$mail->Password='Your Password';
$mail->setFrom('Your Email', 'OTP Verification');
$mail->addAddress($_POST["email"]);
$mail->isHTML(true);
$mail->Subject="Your verify code";
$mail->Body="<p>Dear user, </p> <h3>Your verify OTP code is $otp <br></h3>";
if(!$mail->send()){
?>
<script>
alert("<?php echo "Register Failed, Invalid Email "?>");
</script>
<?php
}
else{
?>
<script>
alert("<?php echo "Login Successfully Done, OTP sent to " . $email ?>");
window.location.replace('logverification.php');
</script>
<?php
}
}
}
else {
$msg = "<div class='alert alert-danger'>Email or password do not match.</div>";
}
}
?>
<!DOCTYPE html>
<html lang="zxx">
<head>
<title>Login Form</title>
<!-- Meta tag Keywords -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8" />
<meta name="keywords"
content="Login Form" />
<!-- //Meta tag Keywords -->
<link href="//fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet">
<!--/Style-CSS -->
<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
<!--//Style-CSS -->
<script src="https://kit.fontawesome.com/af562a2a63.js" crossorigin="anonymous"></script>
</head>
<body>
<!-- form section start -->
<section class="w3l-mockup-form">
<div class="container">
<!-- /form -->
<div class="workinghny-form-grid">
<div class="main-mockup">
<div class="alert-close">
<span class="fa fa-close"></span>
</div>
<div class="w3l_form align-self">
<div class="left_grid_info">
<img src="images/image.svg" alt="">
</div>
</div>
<div class="content-wthree">
<h2>Login Now</h2>
<p>login with your valid username and password </p>
<?php echo $msg; ?>
<form action="" method="post">
<input type="email" class="email" name="email" placeholder="Enter Your Email" required>
<input type="password" class="password" name="password" placeholder="Enter Your Password" style="margin-bottom: 2px;" required>
<p><a href="forgot-password.php" style="margin-bottom: 15px; display: block; text-align: right;">Forgot Password?</a></p>
<button name="submit" name="submit" class="btn" type="submit">Login</button>
</form>
<div class="social-icons">
<p>Create Account! <a href="register.php">Register</a>.</p>
</div>
</div>
</div>
</div>
<!-- //form -->
</div>
</section>
<!-- //form section start -->
<script src="js/jquery.min.js"></script>
<script>
$(document).ready(function (c) {
$('.alert-close').on('click', function (c) {
$('.main-mockup').fadeOut('slow', function (c) {
$('.main-mockup').remove();
});
});
});
</script>
</body>
</html>