I can get the form to recognize the PHP file, but I keep getting the error message when using the JavaScript submit link. If it’s just a regular input submit button everything works. Am I missing some JavaScript or PHP code? Any help would be appreciated. Thanks!
HTML
<form action="sendform.php" id="form1" name="form1" method="post">
<fieldset>
<label>Enter Your Name:
<input id="name" name="name" type="text">
</label>
<label>Enter Your Email:
<input id="email" name="email" type="email">
</label>
<label id="message" name="message" class="txt">Enter Your Message:
<textarea></textarea>
</label>
<span class="btns">
<a href="javascript:document.getElementById('form1').reset()" class="mrk">Reset</a>
<a href="javascript:document.getElementById('form1').submit()" class="mrk">Submit</a>
</span>
</fieldset>
</form>
PHP
<?php
if( isset( $_POST['submit'] ) || isset( $_POST['submit_x'] ) ) {
$to = "email@email.com";
$subject = "Contact Form";
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$message = $_POST['message'] ;
$body = "
Name: $name
Email: $email
Message: $message
";
echo "Your information has been submitted. An associate will contact you shortly.";
mail($to, $subject, $body);
} else {
echo "We're sorry but your form could not be sent at this time.";
}
?>