-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforgot_password.php
59 lines (50 loc) · 2.09 KB
/
forgot_password.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
<?php
$errors = array('email_not_valid' => false, 'email_not_found' => false);
if (isset($_POST['get_password'])) {
require_once './utils.php';
require_once './db/db_connect.php';
require_once './utils/swiftmailer/lib/swift_required.php';
$email = Util::cleanRegularInputField($_POST['email']);
if (!Util::validateEmailAddress($email))
$errors['email_not_valid'] = true;
if (!Util::getEmailAddressByName($mysqli, $email)) {
$errors['email_not_found'] = true;
}
if (!$errors['email_not_valid'] && !$errors['email_not_found']) {
$random_password = Util::generateRandomPassword();
User::updatePasswordWhereEmail($mysqli, $random_password, $email);
UtilEmail::sendNewPaswordEmail($email, $random_password);
header('Location: forgot_password_success.php');
}
}
require_once 'header.php';
?>
<div>Introduceti adresa de email pe care ati folosit-o la crearea
contului.
</div>
<form action="forgot_password.php" name="contact" method="post">
<table align="center" class="backgroundForm" cellspacing="3"
cellpadding="3" border="0">
<tr>
<td colspan="2" class="headerPageTextSmall">Recuperare parola</td>
</tr>
<tr>
<td width="80px" valign="top">Adresa email</td>
<td valign="top"><input class="inputText" type="text" name="email"
value=""/> <?php if ($errors['email_not_valid']): ?> <br/>
<div class="error">Adresa de email nu este valida</div> <?php elseif ($errors['email_not_found']): ?>
<br/>
<div class="error">Adresa de email nu apartine vreunui cont</div> <?php endif ?>
</td>
</tr>
<tr>
<td></td>
<td align="left">
<hr size="1"/>
<input class="button" type="submit"
value="Recupereaza parola" name="get_password"/>
</td>
</tr>
</table>
</form>
<?php require_once 'footer.php'; ?>