-
Notifications
You must be signed in to change notification settings - Fork 0
/
contacts.php
119 lines (97 loc) · 5.62 KB
/
contacts.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require '../PHPMailer/src/Exception.php';
require '../PHPMailer/src/PHPMailer.php';
require '../PHPMailer/src/SMTP.php';
if( isset($_POST['travel']) && !empty($_POST['travel']) &&
isset($_POST['name']) && !empty($_POST['name']) &&
isset($_POST['gender']) && !empty($_POST['gender']) &&
isset($_POST['birth-date']) && !empty($_POST['birth-date']) &&
isset($_POST['city']) && !empty($_POST['city']) &&
isset($_POST['country']) && !empty($_POST['country']) &&
isset($_POST['email']) && !empty($_POST['email']) &&
isset($_POST['message']) && !empty($_POST['message']) ) {
// -------------- PHPMailer() ----------------------//
// -------------------------------------------------//
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = ''; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = ''; // SMTP username
$mail->Password = ''; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
// Recipients
$mail->setFrom('[email protected]', 'Form di contatto');
$mail->addAddress('[email protected]');
$mail->addAddress('[email protected]');
$mail->addReplyTo($_POST['email'], $_POST['name']);
//Content
$mail->isHTML(true);
$mail->Subject = 'Form inviato da '.$_POST['name'];
$mail->Body = 'Nome: <b>'.$_POST['name'].'</b><br>';
$mail->Body .= 'Viaggio: <b>'.$_POST['travel'].'</b><br>';
$mail->Body .= 'Genere: <b>'.$_POST['gender'].'</b><br>';
$mail->Body .= 'Data di nascita: <b>'.$_POST['birth-date'].'</b><br>';
$mail->Body .= 'Città: <b>'.$_POST['city'].'</b><br>';
$mail->Body .= 'Paese: <b>'.$_POST['country'].'</b><br><br>';
$mail->Body .= 'Messaggio: <br>'.$_POST['message'];
$mail->AltBody = 'Nome: '.$_POST['name'].PHP_EOL;
$mail->AltBody .= 'Viaggio: '.$_POST['travel'].PHP_EOL;
$mail->AltBody .= 'Genere: '.$_POST['gender'].PHP_EOL;
$mail->AltBody .= 'Data di nascita: '.$_POST['birth-date'].PHP_EOL;
$mail->AltBody .= 'Città: '.$_POST['city'].PHP_EOL;
$mail->AltBody .= 'Paese: '.$_POST['country'].PHP_EOL;
$mail->AltBody .= PHP_EOL;
$mail->AltBody .= 'Messaggio:'.PHP_EOL.$_POST['message'];
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
$form_button_label = "Mail Sent!";
} else {
$form_button_label = "Submit";
}
?>
<?php include("first.php"); ?>
<main>
<div id="contact-us">
<?php include("header.php"); ?>
<div id="contact-text" class="block">
<h2>Contact Us</h2>
<p>If you are interested in receiving more information or booking a vacation, please fill the form.</p>
<div id="contact-form" class="block">
<form action="../contacts.php#contact-form" method="post" id="contact-form-form">
<select name="travel" placeholder="Request of information for (Select)">
<option>Galles 1</option>
<option>Galles 2</option>
<option>Galles 3</option>
<option>Galles 4</option>
<option>Galles 5</option>
<option>Arcachon 1</option>
<option>Arcachon 2</option>
<option>Arcachon 3</option>
<option>Somo 1</option>
<option>Somo 2</option>
<option>Somo 3</option>
<option>Honolulu</option>
</select>
<input type="text" name="name" placeholder="Name" required><br>
<input type="text" name="gender" placeholder="Gender" required><br>
<input type="text" name="birth-date" placeholder="Date of birth" required><br>
<input type="text" name="city" placeholder="City" required><br>
<input type="text" name="country" placeholder="Country" required><br>
<input type="text" name="email" placeholder="E-mail" required><br>
<textarea name="message" placeholder="Your message..." required></textarea>
<button type="submit" form="contact-form-form" value="submit"><?php echo $form_button_label ?></button>
</form>
</div>
</div>
</div>
</main>
<?php include("footer.php"); ?>