I need to make a webform for users to input their information, choose a few selections from dropdown menus, and include an attachment. When submitting this form, it should generate and send an email to me.
All of the fields work (in that, they show up in the email I receive) the attachment (I have NO IDEA how to get attachments working). I have only had an intro to HTML course and never learned PHP, and it seems that no amount of googling is getting me the answer I want without completely rewriting all of my code. I'm hoping it's a quick fix, something I'm just overlooking.
Here is my HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div id="container">
<header>
</header>
<div id="maincontent">
<script>
$(document).ready(function() {
$(':text:first').focus();
});
</script>
<div id="form_container">
<form action="sendemail.php" method="post" enctype="multipart/form-data">
<ul id="emailform">
<li>
<label for="ef_title">Title: </label>
<span class="fieldbox"><input type="text" name="ef_title" required="required"></span>
</li>
<li>
<label for="ef_users">Users Impacted: </label>
<span class="fieldbox"><input type="text" name="ef_users" required="required"></span>
</li>
<li>
<label for="ef_datetime">Date/Time: </label>
<span class="fieldbox"><input type="datetime" name="ef_datetime" required="required"></span>
</li>
<li>
<label for="ef_priority">Priority: </label>
<p>
<select name="selectpri" required="required">
<option value="">Select...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</p>
<!-- <span class="fieldbox"><input type="datetime" name="ef_datetime" required="required"></span> -->
</li>
<li>
<label for="ef_blocking">Blocking: </label>
<p>
<select name="selectblock" required="required">
<option value="">Select...</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
</p>
</li>
<li>
<label for="ef_url">URL of Observed Behavior: </label>
<span class="fieldbox"><input type="url" name="ef_url" required="required"></span>
</li>
<li>
<label for="ef_desc">Description of Behavior: </label>
<span class="msgbox"><textarea class="area" name="ef_desc" required="required"></textarea></span>
</li>
<li>
<label for="ef_results">Expected Results: </label>
<span class="msgbox"><textarea class="area" name="ef_results" required="required"></textarea></span>
</li>
<li>
<label for="ef_repro">Repro Steps: </label>
<span class="msgbox"><textarea class="area" name="ef_repro" required="required"></textarea></span>
</li>
<li>
<label for='uploaded_file'>Select A File To Upload:</label>
<input type="file" name="file" id="file">
</li>
</ul>
<input id="sendbutton" type="submit" value="Send">
<input id="clearbutton" type="reset" value="Clear">
<br /><br />
</form>
</div>
</div>
<footer>
</footer>
</div>
</body>
</html>
And here is my PHP code:
<?php
$field_title = $_POST['ef_title'];
$field_users = $_POST['ef_users'];
$field_datetime = $_POST['ef_datetime'];
$field_priority = $_POST['selectpri'];
$field_blocking = $_POST['selectblock'];
$field_url = $_POST['ef_url'];
$field_desc= $_POST['ef_desc'];
$field_results = $_POST['ef_results'];
$field_repro = $_POST['ef_repro'];
$field_attach = $_POST['file'];
$mail_to = 'katcole@uw.edu';
$subject = $field_title;
$body_message .= 'Title: '.$field_title."\n";
$body_message .= 'Users: '.$field_users."\n";
$body_message .= 'Date/Time: '.$field_datetime."\n";
$body_message .= 'Priority: '.$field_priority."\n";
$body_message .= 'Blocking: '.$field_blocking."\n";
$body_message .= 'URL of Observed Behavior: '.$field_url."\n";
$body_message .= 'Description of Behavior: '.$field_desc."\n";
$body_message .= 'Expected Results: '.$field_results."\n";
$body_message .= 'Repro Steps: '.$field_repro."\n";
$body_message .= 'Attachments: '.$field_attach."\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'index.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to v-jacoca@microsoft.com');
window.location = 'index.html';
</script>
<?php
}
?>
Thank you for your help in this matter! :)