-
Notifications
You must be signed in to change notification settings - Fork 0
/
forgpass.php
148 lines (117 loc) · 3.18 KB
/
forgpass.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
<?php include("h&f/header.php"); ?>
<?php
include("dbconnect.php");
require 'includes/PHPMailer.php';
require 'includes/SMTP.php';
require 'includes/Exception.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$email = $_POST['email'];
if (!empty($email)) {
$sql = "select * from user where Email = '$email' ";
$result = mysqli_query($conn, $sql);
if ($result) {
$NID = mysqli_fetch_assoc($result);
$n = $NID['NationalID'];
$query = "select * from user where NationalID = '$n' ";
$r = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
$user_data = mysqli_fetch_assoc($r);
$ud = $user_data['id'];
$to_email = $email;
//sending mail part start
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = "true";
$mail->SMTPSecure = "tls";
$mail->Port = "587";
$mail->Username = "mail address from which you want to send mail to customers and admin";
$mail->Password = "mail address password";
$mail->IsHTML(true);
$mail->Subject = "Verification Code";
$mail->setFrom("mail address from which you want to send mail to customers and admin", "Ishrat");
$se_email = $to_email;
$body = rand(100000, 1000000);
//$mail->Body =rand(100000,1000000);
$mail->Body = $body;
$mail->addAddress($se_email);
if ($mail->Send()) {
$mail->smtpClose();
echo "Successful";
} else {
echo "error";
}
//sending mail part end
$plaintext_password = $body;
$hash = password_hash(
$plaintext_password,
PASSWORD_DEFAULT
);
header("Location: newpas.php?ID=$ud &VID=$hash");
die;
}
}
echo "wrong Email Address";
} else {
echo "Field is Empty!";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<style>
html,
body {
height: 100%;
}
body {
background-image: url("picture/car3.png");
background-repeat: no-repeat;
background-size: 100% 100%;
}
#box {
background-color: #c4c3bb;
margin: auto;
width: 500px;
height: 500px;
padding: 50px;
color: black;
font-size: 20px;
}
input[type=submit] {
color: white;
background-color: green;
border: none;
padding-top: 10px;
margin-left: 180px;
padding: 4px 10px;
font-size: 20px;
}
</style>
</head>
<body>
<div id="box">
<span>
<h1>Enter Your Email Here</h1>
</span><br><br><br>
<form method="post" action="">
<table cellpadding="2">
<div class="form-group">
<tr>
<td style=" padding-top: 15px;padding-bottom: 15px;padding-right:15px;font-size:25px"><label for="name">Email:</label></td>
<td style=" padding-top: 15px;padding-bottom: 15px;padding-left:30px">
<input class="form-control" style="height:50px;width:250px" type="text" name="email" placeholder="email">
</td>
</tr>
</div>
</table><br><br><br>
<input class="btn btn-success" type="submit" value="Verify">
</form>
</div>
</body>
</html>
<?php include("h&f/footer.php"); ?>