I have a basic PHP contact form using JS validation for empty fields, format checks, etc, which all work fine. I now need to add a mail() using the user input.
I've made a version work, using some basic validation in PHP and comment out the JS, but I would like to keep the JS because (a) it's client-side, and (b) it took me a while to get it to work and I don't want to waste my efforts!
My <FORM> statement has "onsubmit="return validateForm(this)" and my Submit button is of type "submit".
The 'validateForm' script works fine, and returns "true" once the form is clean.
I now need to send a mail message when the form has been validated.
I'm not sure whether I should/can include the mail send in the JS script (before returning true), or add a mail() statement somewhere in the PHP code.
I really don't want to mess around with this any more than I have to, so can I please get a straightforward, clear response to what is probably is a much-asked question?