I have extremely little knowledge of PHP and was trying to make a contact form for the website I'm helping to develop. The PHP form sends the email but for whatever reason doesn't replace the variables with the input fields from the contact page. The website is SWFDA. Here is the PHP form I created:
<?php
if(!isset($_POST['submit'])) {
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
$email_from = 'myemail@website.com';
$email_to = 'myemail@website.com';
$email_subject = 'Contact Form Submission (Under testing)';
$email_body = 'You have received a form submission from $name .
Email: $visitor_email .
Here is the message: $message'.;
mail($email_to,$email_subject,$email_body);
header('Location: contact-sent.html');
}
?>
This is the HTML for the form.
<form method="post" action="contactForm.php">
<div class="row uniform">
<div class="6u 12u$(large) 6u(medium) 12u$(xsmall)">
<label for="name">Name</label>
<input type="text" name="name" id="name" required/>
</div>
<div class="6u$ 12u$(large) 6u$(medium) 12u$(xsmall)">
<label for="email">Email</label>
<input type="email" name="email" id="email" required/>
</div>
<div class="12u$">
<label for="message">Message</label>
<textarea name="message" id="message" rows="5" required></textarea>
</div>
<div class="12u$">
<ul class="actions">
<li><input type="submit" value="Send Message" class="special" /></li>
<li><input type="reset" value="Reset" /></li>
</ul>
</div>
</div>
</form>
The received email looks like:
You have received a form submission from $name.
Email: $visitor_email.
Here is the message: $message.