-
Notifications
You must be signed in to change notification settings - Fork 0
/
proses_send_code-verification.php
63 lines (51 loc) · 1.78 KB
/
proses_send_code-verification.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
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
include("database/config.php");
$emailSender = "muchammadfachrisyakur@gmail.com";
$nameOfTheSender = "My Notes";
$emailSubject = "Kode forgot password acount";
if(isset($_POST['sendCode'])){
$messageCode = htmlspecialchars($_POST['kodeVerifikasiEmail']);
$username = htmlspecialchars($_POST['username']);
$emailUser = htmlspecialchars($_POST['emailUser']);
$sql = "UPDATE user SET kode_verifikasi='$messageCode' WHERE username='$username'";
$query = mysqli_query($db,$sql);
if($query){
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Username = $emailSender;
$mail->Password = 'iisd miix whcc hvua';
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->SMTPDebug = 2;
$mail->setFrom($emailSender,$nameOfTheSender);
$mail->addAddress($emailUser);
$mail->isHTML(true);
$mail->Subject = $emailSubject;
$mail->Body = $messageCode;
$send = $mail->send();
if($send){
$sendFile = "<script>
alert('Kode verifikasi berhasil dikirimkan');
window.location.href = 'forgotPassword.php?sending=benar&username=" . $username . "';
</script>";
echo $sendFile;
}else{
echo "<script>
alert('Kode verifikasi gagal dikirimkan');
window.location.href = 'forgotPassword.php?sending=salah';
</script>";
}
}else{
echo "<script>
alert('Gagal mengirin kode verifikasi!!');
</script>";
}
}
?>