forked from ponaravindb/Hospital-Management-System
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.php
executable file
·66 lines (54 loc) · 1.57 KB
/
contact.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
64
65
66
<?php
use PHPMailer\PHPMailer\PHPMailer;
if(isset($_POST['btnSubmit']))
{
$name = $_POST['txtName'];
$email = $_POST['txtEmail'];
$contact = $_POST['txtPhone'];
$subject = $_POST['txtSubject'];
$message = $_POST['txtMsg'];
require_once "PHPMailer/PHPMailer.php";
require_once "PHPMailer/SMTP.php";
require_once "PHPMailer/Exception.php";
$mail = new PHPMailer();
//SMTP Settings
$mail -> isSMTP();
$mail -> Host = "smtp.gmail.com";
$mail -> SMTPAuth = true;
$mail -> Username = "[email protected]";
$mail -> Password = 'hxfvasegvmpzclzg';
$mail -> Port = 465; //587
$mail -> SMTPSecure = "ssl"; //tls
//Email Settings
$mail -> isHTML(true);
$mail -> setFrom($email, $name);
$mail -> addAddress("[email protected]");
$mail -> Subject = $subject;
$mail -> Body = $message;
if($mail->send()){
$status = "Success";
$response = "Email sent!";
}
else{
$status = "Success";
$response = "Something is wrong: <br><br>" . $mail->ErrorInfo;
}
//exit(json_encode(array("status" => $status, "response" => $response)));
}
$con=mysqli_connect("localhost","root","","hmsdb");
if(isset($_POST['btnSubmit']))
{
$name = $_POST['txtName'];
$email = $_POST['txtEmail'];
$contact = $_POST['txtPhone'];
$message = $_POST['txtMsg'];
$query="insert into contact(name,email,contact,message) values('$name','$email','$contact','$message');";
$result = mysqli_query($con,$query);
if($result)
{
echo '<script type="text/javascript">';
echo 'alert("Message sent successfully!");';
echo 'window.location.href = "contact.html";';
echo '</script>';
}
}