-
Notifications
You must be signed in to change notification settings - Fork 0
/
appointment_form.php
50 lines (39 loc) · 1.61 KB
/
appointment_form.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
<?php
use PHPMailer\PHPMailer\PHPMailer;
require_once "PHPMailer/src/PHPMailer.php";
require_once "PHPMailer/src/SMTP.php";
require_once "PHPMailer/src/Exception.php";
$mail = new PHPMailer(true);
$alert = '';
if (isset($_POST['submits'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$date = $_POST['date'];
$department = $_POST['department'];
$doctor = $_POST['doctor'];
$body = $_POST['message'];
try {
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'tauqeer.ali.9934@gmail.com'; // Gmail address which you want to use as SMTP server
$mail->Password = 'yxhraoojdelmpynd'; // Gmail address Password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = '587';
$mail->isHTML(true);
$mail->setFrom($email, $name);
$mail->addAddress("tauqeer.ali.9934@gmail.com");
$mail->Subject = $name;
$mail->Body = "<h3>Name : $name <br>Email: $email <br>Phone_Number: $phone <br>Date: $date <br>Department: $department <br>Doctor: $doctor <br>Message : $body</h3>";
$mail->send();
$alert = '<div class="alert-success">
<span>Appointment Sent! We will contact you soon.</span>
</div>';
} catch (Exception $e){
$alert = '<div class="alert-error">
<span>'.$e->getMessage().'</span>
</div>';
}
}
?>