I'm new to coding, what I'm trying to do is to make contact form, to send emails to myself
My question is: how do I connect these two codes together? I want when I press "send button" to capture all fields from HTML then use PHP code to send the email to myself
This is my PHP file called function.php
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$mailTo = "xxxx@xxxx.com";
$headers = "From: ".$mailFrom;
$txt = "You have received an e-mail from ".$name.".\n\n".$message;
mail($mailTo, $subject, $txt, $headers);
header("Location: index.php?mailsend");
}
?>
And this is my html file called index.html
<div class="row">
<div class="col-lg-12 m-30px-b sm-m-15px-b">
<div class="contact-form">
<h4 class="dark-color font-alt m-20px-b">If you need help! feel free to contact me!</h4>
<form class="contactform" method="post">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input id="name" name="name" type="text" placeholder="Name" class="validate form-control" required="">
<span class="input-focus-effect theme-bg"></span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input id="email" type="email" placeholder="Email" name="email" class="validate form-control" required="">
<span class="input-focus-effect theme-bg"></span>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<textarea id="message" placeholder="Your Comment" name="message" class="form-control" required=""></textarea>
<span class="input-focus-effect theme-bg"></span>
</div>
</div>
<div class="col-md-12">
<div class="send">
<button class="btn btn-theme" type="submit" name="send"> send message</button>
</div>
<span class="output_message"></span>
</div>
</div>
</form>
</div>
</div> <!-- col -->
</div>