Skip to content

Commit

Permalink
update mail
Browse files Browse the repository at this point in the history
  • Loading branch information
lechiluan committed Apr 16, 2023
1 parent cace0d6 commit c5595b4
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 31 deletions.
4 changes: 2 additions & 2 deletions QAC_All_Ideas.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ class="btn btn-outline-secondary btn-sm comment-toggle"
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'greenwich.qa@gmail.com';
$mail->Password = 'qevnixqcokwnulix';
$mail->Username = 'qa.greenwich@gmail.com';
$mail->Password = 'rwdibyoqadzmaxbw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

Expand Down
4 changes: 2 additions & 2 deletions QAC_Idea_By_Department.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ class="btn btn-outline-secondary btn-sm comment-toggle"
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'greenwich.qa@gmail.com';
$mail->Password = 'qevnixqcokwnulix';
$mail->Username = 'qa.greenwich@gmail.com';
$mail->Password = 'rwdibyoqadzmaxbw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

Expand Down
2 changes: 1 addition & 1 deletion QAC_Send_Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'qevnixqcokwnulix';
$mail->Password = 'rwdibyoqadzmaxbw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

Expand Down
4 changes: 2 additions & 2 deletions QAC_Topic_Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ class="btn btn-outline-secondary btn-sm comment-toggle"
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'greenwich.qa@gmail.com';
$mail->Password = 'qevnixqcokwnulix';
$mail->Username = 'qa.greenwich@gmail.com';
$mail->Password = 'rwdibyoqadzmaxbw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

Expand Down
4 changes: 2 additions & 2 deletions QAM_Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ class="d-flex align-items-center text-decoration-none text-dark" id="manage-topi
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'greenwich.qa@gmail.com';
$mail->Password = 'qevnixqcokwnulix';
$mail->Username = 'qa.greenwich@gmail.com';
$mail->Password = 'rwdibyoqadzmaxbw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

Expand Down
4 changes: 2 additions & 2 deletions QAM_Ideas.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@ class="btn btn-outline-secondary btn-sm comment-toggle"
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'greenwich.qa@gmail.com';
$mail->Password = 'qevnixqcokwnulix';
$mail->Username = 'qa.greenwich@gmail.com';
$mail->Password = 'rwdibyoqadzmaxbw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

Expand Down
8 changes: 4 additions & 4 deletions Staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ class="btn btn-primary"><i class="fas fa-download"></i>Download Documents</a>
// $mail->isSMTP();
// $mail->Host = 'smtp.gmail.com';
// $mail->SMTPAuth = true;
// $mail->Username = 'greenwich.qa@gmail.com';
// $mail->Password = 'qevnixqcokwnulix';
// $mail->Username = 'qa.greenwich@gmail.com';
// $mail->Password = 'rwdibyoqadzmaxbw';
// $mail->SMTPSecure = 'tls';
// $mail->Port = 587;
//
Expand Down Expand Up @@ -661,8 +661,8 @@ class="btn btn-primary"><i class="fas fa-download"></i>Download Documents</a>
// $mail->isSMTP();
// $mail->Host = 'smtp.gmail.com';
// $mail->SMTPAuth = true;
// $mail->Username = 'greenwich.qa@gmail.com';
// $mail->Password = 'qevnixqcokwnulix';
// $mail->Username = 'qa.greenwich@gmail.com';
// $mail->Password = 'rwdibyoqadzmaxbw';
// $mail->SMTPSecure = 'tls';
// $mail->Port = 587;
//
Expand Down
8 changes: 4 additions & 4 deletions Staff_Hot.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@ class="btn btn-primary"><i class="fas fa-download"></i>Download Documents</a>
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'greenwich.qa@gmail.com';
$mail->Password = 'qevnixqcokwnulix';
$mail->Username = 'qa.reenwich@gmail.com';
$mail->Password = 'rwdibyoqadzmaxbw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

Expand Down Expand Up @@ -675,8 +675,8 @@ class="btn btn-primary"><i class="fas fa-download"></i>Download Documents</a>
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'greenwich.qa@gmail.com';
$mail->Password = 'qevnixqcokwnulix';
$mail->Username = 'qa.reenwich@gmail.com';
$mail->Password = 'rwdibyoqadzmaxbw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

Expand Down
8 changes: 4 additions & 4 deletions Staff_Last.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,8 @@ class="btn btn-primary"><i class="fas fa-download"></i>Download Documents</a>
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'greenwich.qa@gmail.com';
$mail->Password = 'qevnixqcokwnulix';
$mail->Username = 'qa.greenwich@gmail.com';
$mail->Password = 'rwdibyoqadzmaxbw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

Expand Down Expand Up @@ -665,8 +665,8 @@ class="btn btn-primary"><i class="fas fa-download"></i>Download Documents</a>
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'greenwich.qa@gmail.com';
$mail->Password = 'qevnixqcokwnulix';
$mail->Username = 'qa.greenwich@gmail.com';
$mail->Password = 'rwdibyoqadzmaxbw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

Expand Down
8 changes: 4 additions & 4 deletions Staff_MyPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ class="btn btn-primary"><i class="fas fa-download"></i>Download Documents</a>
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'greenwich.qa@gmail.com';
$mail->Password = 'qevnixqcokwnulix';
$mail->Username = 'qa.greenwich@gmail.com';
$mail->Password = 'rwdibyoqadzmaxbw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

Expand Down Expand Up @@ -618,8 +618,8 @@ class="btn btn-primary"><i class="fas fa-download"></i>Download Documents</a>
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'greenwich.qa@gmail.com';
$mail->Password = 'qevnixqcokwnulix';
$mail->Username = 'qa.greenwich@gmail.com';
$mail->Password = 'rwdibyoqadzmaxbw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

Expand Down
8 changes: 4 additions & 4 deletions Staff_PostIdeas.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ class="text-primary">terms
// $mail->isSMTP();
// $mail->Host = 'smtp.gmail.com';
// $mail->SMTPAuth = true;
// $mail->Username = 'greenwich.qa@gmail.com';
// $mail->Password = 'qevnixqcokwnulix';
// $mail->Username = 'qa.greenwich@gmail.com';
// $mail->Password = 'rwdibyoqadzmaxbw';
// $mail->SMTPSecure = 'tls';
// $mail->Port = 587;
//
Expand Down Expand Up @@ -711,8 +711,8 @@ class="btn btn-outline-secondary btn-sm comment-toggle"
// $mail->isSMTP();
// $mail->Host = 'smtp.gmail.com';
// $mail->SMTPAuth = true;
// $mail->Username = 'greenwich.qa@gmail.com';
// $mail->Password = 'qevnixqcokwnulix';
// $mail->Username = 'qa.greenwich@gmail.com';
// $mail->Password = 'rwdibyoqadzmaxbw';
// $mail->SMTPSecure = 'tls';
// $mail->Port = 587;
//
Expand Down
62 changes: 62 additions & 0 deletions Top_Ideas.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,69 @@ class="btn btn-outline-secondary btn-sm comment-toggle"
</div>
<?php } ?>
</div>
<?php
include("connection.php");
// add comment for topic
if (isset($_POST['add-comment'])) {
$ideaID = $_POST['ideaID'];
$content = $_POST['commentContent'];
$staffID = $_SESSION['staff_id'];
$commentDate = date("Y-m-d H:i:s");
$isAnonymous = isset($_POST['anonymousComment']) ? 1 : 0;

$sql = "INSERT INTO Comment (CommentContent, StaffID, IdeaID, is_anonymous, CommentDate) VALUES ('$content', '$staffID', '$ideaID', '$isAnonymous', '$commentDate')";

if (mysqli_query($conn, $sql)) {
// The author of an idea receives an automatic email notification whenever a comment is submitted to any of their ideas.
$sql2 = "SELECT * FROM Idea WHERE IdeaID = '$ideaID'";
$result2 = mysqli_query($conn, $sql2);
$row2 = mysqli_fetch_assoc($result2);
$authorID = $row2['StaffID'];
$sql3 = "SELECT * FROM Staff WHERE StaffID = '$authorID'";
$result3 = mysqli_query($conn, $sql3);
$row3 = mysqli_fetch_assoc($result3);
$authorEmail = $row3['Email'];
$authorName = $row3['StaffName'];
$to = $authorEmail;
$subject = "New comment on your idea";
$message = "Dear " . $row3['StaffName'] . ",<br><br> A new comment has been submitted to your idea $row2[Title].<br><br>";
$message .= 'Comment: ' . $content . '<br><br>';
$message .= 'Please login at https://greenwichideas.cleverapps.io/ to your account to view the comment.<br><br>';
$message .= 'Thank you,<br>Greenwich Quality Assurance Manager';

// Set up the email headers
$mail = new PHPMailer\PHPMailer\PHPMailer();

try {
// Server settings
$mail->SMTPDebug = 0;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'rwdibyoqadzmaxbw';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

// Recipients
$mail->setFrom('[email protected]', 'Greenwich QA');
$mail->addAddress($to, $authorName);

// Content
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->send();
echo "<script>alert('Comment added successfully!')</script>";
echo "<script>window.location.href='Staff_PostIdeas.php?topic=$topic'</script>";
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
} else {
echo "<script>alert('Error: " . $sql . "<br>" . mysqli_error($conn) . "')</script>";
}
}
?>
<div class="col-md-6">
<?php
// Get 5 ideas with the most comments
Expand Down

0 comments on commit c5595b4

Please sign in to comment.