-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindpw.php
62 lines (51 loc) · 1.57 KB
/
findpw.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
<?php
include $_SERVER['DOCUMENT_ROOT']. '/dbconn.php';
require $_SERVER['DOCUMENT_ROOT']. '/vendor/phpmailer/phpmailer/PHPMailerAutoload.php';
require $_SERVER['DOCUMENT_ROOT']. '/vendor/phpmailer/phpmailer/class.smtp.php';
$id = $_POST['id'];
$email = $_POST['email'];
$query = mysqli_query($conn,
"select userEmail from users_server
where userStrID='$id' and userEmail='$email'")
or die($conn);
if(mysqli_num_rows($query)==0){
echo 10;
exit;
}
if($data = mysqli_fetch_assoc($query)){
$tempPW = chr(rand(95,122)) . chr(rand(95,122)) . chr(rand(95,122))
. chr(rand(95,122)) . chr(rand(95,122)) . chr(rand(95,122))
. chr(rand(95,122)) . chr(rand(95,122)) . chr(rand(95,122))
. chr(rand(95,122)) . chr(rand(95,122)) . chr(rand(95,122));
$email = $data['userEmail'];
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->CharSet = 'utf-8';
$mail->IsHTML(true);
$mail->Username = "[email protected]";
$mail->Password = "oxrepxwsrgwrlyxf";
$mail->SetFrom('[email protected]', 'MusicWriter');
$mail->AddAddress($email, $id);
$mail->Subject = '임시 비밀번호가 생성 되었습니다';
$mail->Body =
"임시 비밀번호는 ". $tempPW ." 입니다.".
"<br>앱에서 로그인 후 비밀번호를 변경해주세요";
if(!$mail->Send()){
echo 20;
}
else{
mysqli_query($conn,
"update users_server set userPW='$tempPW'
where userStrID='$id'"
) or die($conn);
echo 1;
}
}
else{
echo 30;
}
?>