0

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.

Imperdiet
  • 11
  • 2
  • Lordie, did you even Google that? There must be millions of hits out there for this and I am not exaggerating. – Funk Forty Niner May 01 '17 at 17:42
  • *"Here is the code for the form I have now:"* - I don't see a form or HTML. – Funk Forty Niner May 01 '17 at 17:43
  • I understand what you mean, heck I've spent the best part of 3 hours on it, but I don't know how to make a script to send emails. Using the current parameters, how would I go about doing so? – Imperdiet May 01 '17 at 17:44
  • Fred- this was my code for my form which would ideally send emails. I hope you get what I mean :/ – Imperdiet May 01 '17 at 17:45

0 Answers0