As I am new in programming, I would like to enquire about using html & php simultaneously for form submission.
Basically, the form is made by html, and php is used to automatically send an email to a certain address.
I want to use jquery as well for form validation and for replying with the message: "Thank you for your comment".
However, it seems that I am facing an issue. When I hit "Send", an email is not sent to the9 address I choose, and no message pops up.
I am pretty sure there are errors with the code. Can anyone check and help?
Thanks.
<form id ="myForm" class="myForm" action="submit_student_form.php" method="post">
<h1 class="form-title">My title</h1>
<label>Name*</label>
<input type="text" name="first_name" placeholder="Please put name here" required>
</p>
<p>
<label>Contact*</label>
<input type='tel' name="telephone" placeholder="00000000 968+" maxlength="13" minlength="12" required>
</p>
<p>
<label>Comment</label>
<input type="text" name="comment" placeholder="comment here" size="100">
</p>
<p>
<button type="Submit">Send</button><br>
</form>
<?php
if(isset($_POST['email'])) {
$email_to = "xxx@gmail.com
";
$email_subject = "Subject";
$email_message = "Details Below.\n\n";
$email_message .= "Name*: ".clean_string($first_name)."\n";
$email_message .= "Contact*: ".clean_string($telephone)."\n";
$email_message .= "Comment: ".clean_string($comment)."\n";
mail($email_to, $email_subject, $email_message);
?>
<?php
}
?>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
// wait for the DOM to be loaded
$(document).ready(function() {
// bind 'myForm' and provide a simple callback function
$('#myForm').ajaxForm(function() {
alert("Thank you for your comment!");
});
});
</script>
</head>
So, basically what I need is:
1) Email to be sent to the given address automatically in php upon hitting "Send".
2) jquery to respond with "Thank you for your comment" upon hitting "Send".
I would appreciate your help in this.