I used an anchor tag for my submit button so I think that this is probably why I'm having so much trouble trying to figure this out.
I'm not sure if it's the "href" that is messing it all up. I also would like some assistance with server side validation, not having a lot of experience in PHP, I was only able to validate using JavaScript.
<form id="myform" method="post" name="contact_form" action="process.php">
<input id="cname" type="text" name="name" minlength="2" placeholder="Full Name" class="form-control" required>
<input id="cemail" type="email" name="email" placeholder="Email Address" class="form-control" required>
<textarea id="ccomment" rows="5" name="message" placeholder="Message..." class="form-control" required></textarea>
<div id="send-btn">
<a href="process.php" onClick="$(this).closest('form').submit();" class="btn btn-lg btn-general btn-white" role="button" name="submit">SEND</a>
<asp:Button runat="server" Text="submit"/>
</div>
</form>
This below is my PHP code. Please assist with validations and making it work with an anchor tag. I could have messed up the form somewhere.
<?php ob_start();
if (isset($_POST['submit'])) {
$to = "someoneelse@someone.com";
$name = $_POST['name'];
$email = $_POST['email'];
$txt = $_POST['message'];
$headers = "From: .$email" . "
" .
mail($to,$email,$txt,$headers);
header("Location: index.html");
}
?>