Hello, This is my first attempt at a working php script. I’m trying to simply gather input and email data from an .html5 web contact form. Specially first name, last name, email, telephone and the message. I have been able to get the .php script and .html form communicating, gathering the input and then sending / forwarding the data to an external email, then confirming the message was sent to the user with a browser prompt then redirecting back to the site’s home page. I’m using a basic .html5 form with tags that require input in the fields. However I’m aware the data needs validation and sanitizing for security. I’ve read most of what I can find about this and found some default .php validation and sanitizing functions but have been spinning on implementing them. Help, suggestions, input, code etc. would be very helpful. Thank you
Note: $email2 = ‘[email protected]’ is my workaround to pass the site email server as the sender due to DMARC rejection that occurred with code that placed the form users email into the from header which obviously wasn’t originating from the hosts server. Is there a better way? Thank You
[php]
<?php $first = $_POST['first']; $last = $_POST ['last']; $email = $_POST['email']; $email2 = '[email protected]'; $message = $_POST['message']; $phone = $_POST['phone']; $formcontent=" First: $first \n Last: $last \n Email: $email \n Phone: $phone \n Message: $message"; $recipient ="[email protected]"; $subject = "Contact Form"; $mailheader ="From: $email2 \r\n"; mail($recipient, $subject, $formcontent) or die("Error!"); echo ""; ?>[/php]