0

I'm trying to figure out why this form isn't emailing after submission. I did a test and PHP mail is working correctly on the server. Is something wrong with the headers perhaps?

Thanks in advance for any advice!

     <?php

                        if(!empty($_POST['first-name'])) {

                        $_POST['email'] = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);

                        $agree1 = implode(", ", $_POST['certify-info-true']);
                        $agree2 = implode(", ", $_POST['understand-false-info']);
                        $agree3 = implode(", ", $_POST['final-sig']);

                        foreach($_POST as $name => $value) {
                        $value = filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
                            if($name == 'submit') {
                                //skip
                            }
                            elseif ($name == 'certify-info-true') {
                                $res .= "$name : $agree1 \n \n";
                            }
                            elseif ($name == 'understand-false-info') {
                                $res .= "$name : $agree2 \n \n";
                            }
                            elseif ($name == 'final-sig') {
                                $res .= "$name : $agree3 \n \n";
                            }
                            else {
                            $res .= "$name : $value \n \n";
                            }
                        }

                        //SET here the destination email address and subject line
                        mail('test@testmail.com','Application', "$res", "From: {$_POST['email']}");

                        //SET here the thank you message
                        echo "<h2>Thank you.</h2>";

                        //print_r($_POST);
                        } else {

                    ?>

                    <form action="" id="test" method="POST"></form>
<? } ?>
user1610904
  • 397
  • 3
  • 20

0 Answers0