I'm making a website, and at the moment, I need to use a contact us form in it. I'm an utter novice at PHP, but I do not know what I need to make my form work. I asked my friend and he said I need to have a script that gets the information from the form and sends it to a defined email address. That is done in PHP. How do I do this? Here is the code for the form I have now:
<div class="scroll-to-top" data-offset-top="200" data-spy="affix"></div>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script language="JavaScript" type="text/javascript">
function callmailfun() {
var str = $('#frmcal').serialize();
// ajax to send mail
// not yet implemented serverside. Will throw an error
// serialize to prevent redirect
$.ajax({
type: "POST", url: "req_mail.php", data: str, success: function (msg) {
if (msg == '1') {
result = '<div class="notification_ok">Thank you for your interest <br />we will get back to you at the earliest.</div>';
$("#reset-form").trigger("click");
} else {
result = '<div class="notification_error">Your data could not be received. Try again later</div>';
}
// open the alert box
$('#note').html(result);
openiframe();
}
}); return false;
}
$(document).ready(function (e) {
// set the button to submit mail for the contact form
$("#frmcal").submit(function () {
validate = chk1();
if (validate) {
var str = $(this).serialize();
//prevent reloading of webpage
$.ajax({
type: "POST", url: "req_mail.php",
data: str, success: function (msg) {
alert(msg);
if (msg == '1') {
result = '<div class="notification_ok">Thank you for your interest we will get back to you at the earliest.</div>';
$("#reset-form").trigger("click");
} else {
result = '<div class="notification_error">Your data could not be received. Try again later</div>';
}
// open the alert box
$('#note').html(result);
openiframe();
}
});
} return false;
});
}); function CheckNumericKeyInfo($char, $mozChar) { if ($mozChar != null) { if (($mozChar >= 48 && $mozChar <= 57) || $mozChar == 0 || $mozChar == 45 || $char == 8 || $mozChar == 13) $RetVal = true; else { $RetVal = false; } } else { if (($char >= 48 && $char <= 57) || ($char == 13) || ($char == 45)) $RetVal = true; else { $RetVal = false; } } return $RetVal; }</script>
<!--For custom scroll section-->
I'm confused with where I stand with mailing servers etc, do I really need that for my website? How do I incorporate that into my script? Thank you.