-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction_forgot_password.php
47 lines (38 loc) · 1.3 KB
/
action_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
<?php
/**
* Created by N0B0DY.
* User: me@suvo.me
* Date: 9/15/14
* Time: 1:41 AM
*/
require('core.php');
$Form = new Form();
$Email = new Email();
if( !isset( $_POST['submit'] )) {
redirect('forgot_password.php');
} else{
if( !isset( $_POST['email'] ) || empty($_POST['email']) ) {
$Form->setError('email','Please write your email address');
}
if( $Form->num_errors > 0 ) {
$Form->return_msg_to('forgot_password.php');
} else {
$email = cleanData($_POST['email']);
$user = mysql_fetch_assoc(mysql_query('SELECT * FROM '.TBL_USER.' WHERE email="'.$email.'"'));
if(!$user){
$Form->setError('notFound','User Not Found.');
$Form->return_msg_to('forgot_password.php');
} else {
$Email->setEmailSubject('Forgot Password');
$Email->setMessage('Your password is '.$user['password']);
$Email->setEmailTo($email);
if($Email->sendMail()){
$Form->setError('success','Your password has been sent to your email. Please check your mails.');
$Form->return_msg_to('forgot_password.php');
} else {
$Form->setError('notFound','User Not Found.');
$Form->return_msg_to('forgot_password.php');
}
}
}
}