Trying to create a contact form using html and php with a file upload button
I've created a simple contact form for a website that I am working on, but I need to alter it slightly for another area of the website. I need to be able to add an upload section where the user can upload an image that will then be sent along with their comments. This is my current html and php for the basic form.
<form method="post" action="RMArequest.php">
<label>Name</label>
<input name="name" placeholder="Type Here">
<label>Email</label>
<input name="email" type="email" placeholder="Type Here">
<label>Message</label>
<textarea name="message" placeholder="Type Here"></textarea>
<label>*What is 2+2? (Anti-spam)</label>
<input name="human" placeholder="Type Here">
<input id="submit" name="submit" type="submit" value="Submit">
</form>
_____
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: localhost';
$to = 'name@email.com';
$subject = 'RMA Request';
$human = $_POST['human'];
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if ($name != '' && $email != '') {
if ($human == '4') {
if (mail ($to, $subject, $body, $from)) {
header('Location:thanks.html');
} else {
echo '<p>Something was entered incorrectly. Please try again.</p>';
}
} else if ($_POST['submit'] && $human != '4') {
echo '<p>You answered the anti-spam question incorrectly! Please go back and try again.</p>';
}
} else {
echo '<p>You need to fill in all required fields!!</p>';
}
}
?>
</body>
</html>
