1<?php
2// hàm `session_id()` sẽ trả về giá trị SESSION_ID (tên file session do Web Server tự động tạo)
3// - Nếu trả về Rỗng hoặc NULL => chưa có file Session tồn tại
4if (session_id() === '') {
5 // Yêu cầu Web Server tạo file Session để lưu trữ giá trị tương ứng với CLIENT (Web Browser đang gởi Request)
6 session_start();
7}
8?>
9
10<!DOCTYPE html>
11<html>
12
13<head>
14 <meta charset="UTF-8">
15 <meta name="viewport" content="width=device-width, initial-scale=1.0">
16 <title>NenTang.vn</title>
17
18 <!-- Nhúng file Quản lý các Liên kết CSS dùng chung cho toàn bộ trang web -->
19 <?php include_once(__DIR__ . '/../layouts/styles.php'); ?>
20
21 <link href="/php/myhand/assets/frontend/css/style.css" type="text/css" rel="stylesheet" />
22</head>
23
24<body class="d-flex flex-column h-100">
25 <!-- header -->
26 <?php include_once(__DIR__ . '/../layouts/partials/header.php'); ?>
27 <!-- end header -->
28
29 <main role="main" class="mb-2">
30 <!-- Block content -->
31 <div class="container mt-2">
32 <h1 class="text-center">Liên hệ với Nền tảng</h1>
33 <div class="row">
34 <div class="col col-md-6">
35 <img src="/php/myhand/assets/frontend/img/marketing-1.png" class="img-fluid" />
36 </div>
37 <div class="col col-md-6">
38 <form method="post" action="">
39 <div class="form-group">
40 <label for="email">Email của bạn</label>
41 <input type="email" class="form-control" id="email" name="email" placeholder="Email của bạn">
42 </div>
43 <div class="form-group">
44 <label for="title">Tiêu đề của bạn</label>
45 <input type="text" class="form-control" id="title" name="title" placeholder="Tiêu đề của bạn">
46 </div>
47 <div class="form-group">
48 <label for="message">Lời nhắn của bạn</label>
49 <textarea name="message" class="form-control"></textarea>
50 </div>
51 <button class="btn btn-primary" name="btnGoiLoiNhan">Gởi lời nhắn</button>
52 </form>
53 </div>
54 </div>
55 <div class="row mt-2">
56 <div class="col col-md-12">
57 <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3928.7235485722294!2d105.78061631523369!3d10.039656175103817!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x31a062a768a8090b%3A0x4756d383949cafbb!2zMTMwIFjDtCBWaeG6v3QgTmdo4buHIFTEqW5oLCBBbiBI4buZaSwgTmluaCBLaeG7gXUsIEPhuqduIFRoxqEsIFZp4buHdCBOYW0!5e0!3m2!1svi!2s!4v1556697525436!5m2!1svi!2s" width="100%" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
58 </div>
59 </div>
60 </div>
61
62 <?php
63 // Load các thư viện (packages) do Composer quản lý vào chương trình
64 require_once __DIR__.'/../../vendor/autoload.php';
65
66 // Sử dụng thư viện PHP Mailer
67 use PHPMailer\PHPMailer\PHPMailer;
68 use PHPMailer\PHPMailer\Exception;
69
70 if (isset($_POST['btnGoiLoiNhan'])) {
71 // Lấy dữ liệu người dùng hiệu chỉnh gởi từ REQUEST POST
72 $email = $_POST['email'];
73 $title = $_POST['title'];
74 $message = $_POST['message'];
75
76 // Gởi mail kích hoạt tài khoản
77 $mail = new PHPMailer(true); // Passing `true` enables exceptions
78 try {
79 //Server settings
80 $mail->SMTPDebug = 2; // Enable verbose debug output
81 $mail->isSMTP(); // Set mailer to use SMTP
82 $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
83 $mail->SMTPAuth = true; // Enable SMTP authentication
85 $mail->Password = 'yjkkdiyfjwksktot'; // SMTP password
86 $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
87 $mail->Port = 587; // TCP port to connect to
88 $mail->CharSet = "UTF-8";
89
90 // Bật chế bộ tự mình mã hóa SSL
91 $mail->SMTPOptions = array(
92 'ssl' => array(
93 'verify_peer' => false,
94 'verify_peer_name' => false,
95 'allow_self_signed' => true
96 )
97 );
98
99 //Recipients
102 $mail->addReplyTo($email);
105
106 //Attachments
107 // $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
108 // $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
109
110 //Content
111 $mail->isHTML(true); // Set email format to HTML
112
113 // Tiêu đề Mail
114 $mail->Subject = "[Có người liên hệ] - $title";
115
116 // Nội dung Mail
117 // Lưu ý khi thiết kế Mẫu gởi mail
118 // - Chỉ nên sử dụng TABLE, TR, TD, và các định dạng cơ bản của CSS để thiết kế
119 // - Các đường link/hình ảnh có sử dụng trong mẫu thiết kế MAIL phải là đường dẫn WEB có thật, ví dụ như logo,banner,...
120 $body = <<<EOT
121 Có người liên hệ cần giúp đỡ. <br />
122 Email của khách: $email <br />
123 Nội dung: <br />
124 $message
125EOT;
126 $mail->Body = $body;
127
128 $mail->send();
129 } catch (Exception $e) {
130 echo 'Lỗi khi gởi mail: ', $mail->ErrorInfo;
131 }
132 }
133 ?>
134 <!-- End block content -->
135 </main>
136
137 <!-- footer -->
138 <?php include_once(__DIR__ . '/../layouts/partials/footer.php'); ?>
139 <!-- end footer -->
140
141 <!-- Nhúng file quản lý phần SCRIPT JAVASCRIPT -->
142 <?php include_once(__DIR__ . '/../layouts/scripts.php'); ?>
143
144 <!-- Các file Javascript sử dụng riêng cho trang này, liên kết tại đây -->
145
146</body>
147
148</html>