-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontactform.php
More file actions
168 lines (146 loc) · 7.49 KB
/
contactform.php
File metadata and controls
168 lines (146 loc) · 7.49 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
/**
* New version as of 8/4/18
*/
// echo 'PHP version: ' . phpversion();
ini_set('display_errors',1);
error_reporting(E_ALL);
$msg = '';
$name = $email = $message = "";
if (!empty($_POST['name']) ) {
$name = test_input($_POST['name']);
$email = test_input($_POST["email"]);
$message = test_input($_POST['message']);
require 'contact/vendor/autoload.php';
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->setFrom('contact@vietwar.sitehost-test.iu.edu', 'Vietnam War Stories - test server');
//$mail->addAddress('ejblom@iu.edu', 'John Doe');
$mail->addAddress('vietnamwarstories@gmail.com', 'Vietnam War Gmail Account');
$mail->Subject = 'A message from Vietnam War Stories - test server';
if (!empty($_FILES['userfile']['name']) ) {
// create the body
$body = "Message from: " . $name . "\r\n" . "Contact them: " . $email . "\r\n" . "Their message: " . $message;
// First handle the upload
// Don't trust provided filename - same goes for MIME types
// See http://php.net/manual/en/features.file-upload.php#114004 for more thorough upload validation
// $uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['userfile']['name']));
$uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['userfile']['name']));
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
$mail->Body = $body;
// Attach the uploaded file
$mail->addAttachment($uploadfile, $_FILES['userfile']['name']);
if (!$mail->send()) {
$msg .= "Mailer Error: " . $mail->ErrorInfo;
} else {
$msg .= "<h1>Thanks for contacting us!</h1><p>Your message has been sent. We may contact you about your story<p>";
;
}
} else {
$msg .= '<p>Failed to upload file ' . $uploadfile . ". It may have been too big. Try a file less than 5 mb.<p>";
}
} else {
// create the body
$body = "Message from: " . $name . "\r\n" . "Contact them: " . $email . "\r\n" . "Their message: " . $message;
$mail->Body = $body;
if (!$mail->send()) {
$msg .= "Mailer Error: " . $mail->ErrorInfo;
} else {
$msg .= "<h1>Thanks for contacting us!</h1><p>Your message has been sent. We may contact you about your story<p>";
}
}
} else {
$msg ="<p>You got here the wrong way.</p>";
}
// does some validation
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="css/bootstrap/bootstrap-multiselect.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Cardo" rel="stylesheet">
<link href="css/index.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="js/bootstrap/bootstrap-multiselect.js"></script>
<title>Contact Us</title>
<style>
body {font-family: Arial, Helvetica, sans-serif;}
input[type=text], select, textarea {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
margin-top: 6px;
margin-bottom: 16px;
resize: vertical;
}
input[type=submit] {
background-color: #4CAF50;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type=submit]:hover {
background-color: #45a049;
}
.container {
border-radius: 5px;
background-color: #f2f2f2;
padding: 20px;
}
li { font-family: 'Raleway', sans-serif;
}
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Vietnam War Stories <small>Stories From All Sides</small></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="./index.html"><b>HOME</b></a></li>
<li><a href="./glossary.html"><b>GLOSSARY</b></a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">FILM <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="https://vimeo.com/312861149" target="_blank">Trailer</a></li>
<!-- <li><a href="http://www.ronosgood.com/vietnam-waramerican-war2.html" target="_blank">Film Information</a></li> -->
<li><a href="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.ronosgood.com%2Fvietnam-waramerican-war.html&data=05%7C01%7Cshchua%40iu.edu%7Caa576bdeff9d4437ae7808da60879ba9%7C1113be34aed14d00ab4bcdd02510be91%7C0%7C0%7C637928432790818256%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=6FgpTnViTMiEPi0LNdvTadR0iTLlSp2N3tI%2FE6HyESA%3D&reserved=0" target="_blank">Film Information</a></li>
<li role="separator" class="divider"></li>
<li><a href="https://www.facebook.com/VietnamWarStories/" target="_blank">Facebook</a></li>
<li><a href="https://www.youtube.com/channel/UCOhrQ7v8S5URDi0rf7z6UHw/videos" target="_blank">YouTube</a></li>
</ul>
</li>
<li><a href="./contactform.html"><b>TELL YOUR STORY</b></a></li>
</ul> <!-- /.navbar-nav -->
</div> <!-- #navbar -->
</div> <!-- /.container-fluid -->
</nav> <!-- /.navbar -->
<div class="container">
<?php
echo $msg;
?>
<p>Back to <a href="https://vietnamwarstories.indiana.edu/">Vietnam War Stories</a></p>
</div>
</body>
</html>