-
Notifications
You must be signed in to change notification settings - Fork 2
/
suggest.php
53 lines (43 loc) · 1.49 KB
/
suggest.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
<?php
require("PHPMailerAutoload.php");
include("sendmail.php");
$servername = "localhost";
$username = "root";
$password = "betastar";
$db_name = "insti_webops";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $db_name);
if(isset($_POST["name"]) && isset($_POST["email"]) && isset($_POST["comments"])) {
$name = $_POST["name"];
$email = $_POST["email"];
$comments = $_POST["comments"];
$query = "INSERT into test(name,email,comments) values ('$name','$email','$comments')";
$result = mysqli_query($conn,$query);
echo "Suggestion Sent!\n";
$mail = new PHPMailer;
// $mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "userpassword";
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->From = "[email protected]";
$mail->FromName = "Name here";
$mail->addAddress("[email protected]", "Recipient's name here"); //Change it
$mail->isHTML(true);
$mail->Subject = "Suggestion for Website";
$mail->Body = "Hello. I am " . $name . " and my suggestion for Institute Webops is " . $comments;
$mail->AltBody = "This is the plain text version of the email content";
if($mail->send()) {
echo "Mail sent";
}
else {
echo "Mail could not be sent";
}
}
else {
echo "Failed...";
}
?>