-
Notifications
You must be signed in to change notification settings - Fork 0
/
officerVerificationCodeSendProcess.php
63 lines (55 loc) · 2.51 KB
/
officerVerificationCodeSendProcess.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
require "connection.php";
require "SMTP.php";
require "PHPMailer.php";
require "Exception.php";
use PHPMailer\PHPMailer\PHPMailer;
if(isset($_POST["username"])){
$username = $_POST["username"];
$officerResultset = Database::search("SELECT * FROM `teacher` WHERE `username`='".$username."'");
$officerRownumber = $officerResultset->num_rows;
if($officerRownumber == 1){
$officerData = $officerResultset->fetch_assoc();
function generateUniqId($startNum, $idLenght)
{
$uniqId = uniqid();
$newUniqId = substr($uniqId, intval($startNum), intval($idLenght));
return $newUniqId;
}
$verificationCode = generateUniqId(5,6);
Database::insertUpdateDelete("UPDATE `teacher` SET `verification_code`='".$verificationCode."' WHERE `username`='".$username."'");
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '';
$mail->Password = '';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->setFrom('', 'OSMS');
$mail->addReplyTo('', 'OSMS');
$mail->addAddress($officerData["email"]);
$mail->isHTML(true);
$mail->Subject = 'Academic Officer Signin Verification Code';
$bodyContent = '<div style="width: auto;height: auto;border-radius: 24px;background-image: linear-gradient(24deg, #3972eb, #59ccfa);padding-left: 20px;padding-right: 20px;padding-bottom: 20px;">
<div style="text-align: center;font-size: 13px;font-weight:bold;padding-top:13px;">
<span style="color: #fff;font-size:18px;">Verification Code Is</span>
</div>
<div style="margin-top: 30px;">
<div style="padding-left:5px;padding-top:5px;padding-bottom:5px;padding-right:5px;border-radius: 24px;background-color: rgb(232, 255, 253);box-shadow: 0px 3px 5px 1px rgba(17, 14, 68, 0.1);text-align:center;">
<h3 style="font-size: 14px;color: #135eff;">' . $verificationCode . '</h3>
</div>
</div>
</div>';
$mail->Body = $bodyContent;
if (!$mail->send()) {
echo ("Verification code sending failed");
} else {
echo ("success");
}
}else{
echo("Invalid teacher");
}
}else{
echo("Something went wrong");
}