PHP电子邮件 - 单选按钮导致电子邮件问题

时间:2016-02-18 22:25:33

标签: php forms email

我在一个页面上制作了3个表单,这些表单都是由email-submit.php处理的。其中2个表单按预期工作,但使用单选按钮的表单似乎打破了电子邮件中的样式,并导致我的电子邮件程序认为该邮件是垃圾邮件。某处肯定有错,但我还没能找到它。

导致问题的变量是最佳时间。

我真的很感激任何帮助!

 <?php
    if (isset($_POST["submit"])) {
    $headers = 'From: "Contact Form" <no-reply@email.com>'."\r\n";
    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
        $name = $_POST['name'];
        $email = $_POST['email'];
        $bestTime = $_POST['besttime'];
        $message = '<html><body>';
        $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
        $message .= '<tr style="background: #eee;"><td><strong>Name:</strong> </td><td>' . strip_tags($_POST['name']) . '</td></tr>';
        $message .= "<tr><td><strong>Title:</strong> </td><td>" . strip_tags($_POST['title']) . "</td></tr>";       
        $message .= "<tr><td><strong>Company:</strong> </td><td>" . strip_tags($_POST['company']) . "</td></tr>";           
        $message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['email']) . "</td></tr>";
        $message .= "<tr><td><strong>Phone:</strong> </td><td>" . strip_tags($_POST['phone']) . "</td></tr>";   
        $message .= "<tr><td><strong>Best time:</strong> </td><td>"  . strip_tags($_POST['besttime']) . "</td></tr>";               
        $message .= "<tr><td><strong>Comments:</strong> </td><td>" . strip_tags($_POST['comments']) . "</td></tr>";
        $message .= "</table>";
        $message .= "</body></html>";
        $from = 'no-reply@email.com'; 
        $to = 'email@email.com'; 
        $subject = 'Message from Contact Form';

// If there are no errors, send the email
if (!$errName && !$errEmail && !$errMessage) {
    if (mail ($to,$subject,$message,$headers)) {
        print "<meta http-equiv=\"refresh\" content=\"0;URL=email-success.php\">";
    } else {
        print "<meta http-equiv=\"refresh\" content=\"0;URL=email-error.php\">";
    }
}
    }
?>  

表格:

            <div class="email-me-form">
            <form class="form-horizontal" role="form" method="post" action="email-submit.php">

                <div class="form-group">
                    <label for="name" class="col-sm-2 control-label">Name</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="name" name="name" placeholder="First & Last Name" required autocomplete="off">
                    </div>
                </div>                             

                <div class="form-group">
                    <label for="phone" class="col-sm-2 control-label">Phone</label>
                    <div class="col-sm-10">
                        <input type="phone" class="form-control" id="phone" name="phone" required autocomplete="on" placeholder="xxx-xxx-xxxx">
                    </div>
                </div>

                <div class="form-group">
                    <label style="width: 283px;" for="callTime" class="col-sm-2 control-label">Best Time to Call? (EST) <input style="float: right; margin: 0;" class="submit-button" id="submit" name="submit" type="submit" value="Call Me"></label>

                    <div style="clear: both;"></div>
                    <div style="position: relative; top: -10px;" class="col-sm-10">
                    <div style="float: left;"><input class="radio" type="radio" name="besttime" value="AM" checked>AM</div>
                    <div style="float: left;"><input class="radio" type="radio" name="besttime" value="PM" >PM</div>

                    </div>
                </div>                                     

            </form>     
          </div>

0 个答案:

没有答案