-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate_form.php
88 lines (63 loc) · 2.99 KB
/
template_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
define('ADMIN', '[email protected]');
define('COMPANY', 'dulex');
define('DEFAULT_SUBJECT', 'E-mail from dule localhost');
include 'template_mailsend.php';
$url = 'http://'.$_SERVER['SERVER_NAME'];
$name = isset($_POST['name']) ? $_POST['name'] : null;
$phone = isset($_POST['phone']) ? $_POST['phone'] : null;
$email = isset($_POST['email']) ? $_POST['email'] : null;
$company = isset($_POST['company']) ? $_POST['company'] : null;
$msg = isset($_POST['msg']) ? $_POST['msg'] : null;
$ticket = isset($_POST['ticket']) ? $_POST['ticket'] : null;
$ticketValidity = isset($_POST['validity']) ? $_POST['validity'] : null;
$subject = isset($_POST['subject']) ? $_POST['subject'] : DEFAULT_SUBJECT;
$messageHtml = '
<html>
<head><title>'.$subject.'</title></head>
<body>
<h1>'.$subject.'</h1>';
// Text before data table
$messageHtml .= '';
// Order table html
$messageHtml .= '<br /><table>';
if(isset($name) && $name !== null) { $messageHtml .= '<tr><td width="300">Name: </td><td>'.$name.'</td></tr>'; }
if(isset($company) && $company !== null) { $messageHtml .= '<tr><td width="300">Company: </td><td>'.$company.'</td></tr>'; }
if(isset($phone) && $phone !== null) { $messageHtml .= '<tr><td width="300">Phone: </td><td>'.$phone.'</td></tr>'; }
if(isset($email) && $email !== null) { $messageHtml .= '<tr><td width="300">E-mail: </td><td>'.$email.'</td></tr>'; }
if(isset($msg) && $msg !== null) { $messageHtml .= '<tr><td width="300">Message: </td><td>'.$msg.'</td></tr>'; }
if(isset($ticket) && $ticket !== null) { $messageHtml .= '<tr><td width="300">Ticket: </td><td>'.$ticket.'</td></tr>'; }
if(isset($ticketValidity) && $ticketValidity !== null) { $messageHtml .= '<tr><td width="300">Ticket validity: </td><td>'.$ticketValidity.'</td></tr>'; }
$messageHtml .= '<tr><td width="300">Date:</td><td>'.date('d.m.Y H:i').'</td></tr>';
$messageHtml .= '</table><br />';
// End order table html
// Text after data table
$messageHtml .= '';
$messageHtml .= '</body></html>';
$emailAddr = ADMIN;
$mail = new Mail(ADMIN); // Create an instance of class
$mail->setFromName(COMPANY); // Set up a name in the return address
$response = Array(
'fields' => $mail->send($emailAddr, $subject, $messageHtml),
'captcha' => true,
'hideForm' => true,
'msg' => '
<h3>Thank You!</h3>
<p>Your message has been successfully delivered.</p>
'
);
if ($response['fields']) {
// Success message
$response['msg'] = '
<h3>Thank You!</h3>
<p>Your message has been successfully delivered.</p>
';
} else {
// Error message
$response['msg'] = '
<h3>Error!</h3>
<p>Mail failed.</p>
';
}
echo json_encode($response);
?>