1

所以我有一个表格,可以发送到电子邮件写入文件。但是,它遗漏了一个选择字段。有趣,因为它很好地选择了另一个选择字段,我复制了它。它省略了联系人字段($contact,联系人是如何建立的?)。有任何想法吗?

HTML

<form action="mail.php" method="POST" id="serivce_form">
        <p>Submitter Name :&nbsp; 
            <input type="text" name="submitter_name" /></p>
        <p>Name :&nbsp; 
            <input type="text" name="name" /></p> 
        <p>Time :&nbsp; 
            <input type="text" name="time" /></p>
        <p>Date :&nbsp; 
            <input type="date" name="date" id="date" /></p>
        <p>How was the contact made? </p> 
            <select name="contact" size="1">
                <option selected value="">Select...</option>
                <option value="phone">Phone</option>
                <option value="email">Email</option>
                <option value="other">Other</option>
            </select>
        <p>Phone :&nbsp; 
            <input type="text" name="phone" /></p> 
        <p>Email :&nbsp; 
            <input type="text" name="email" /></p> 
        <p>How did you hear about us? </p>
            <select name="source" size="1">
                <option selected value="">Select...</option>
                <option value="online">Online</option>
                <option value="client referral">Client Referral</option>
                <option value="non client referral">Non Client Referral</option>
                <option value="other">Other</option>
            </select>
        <br />
        <p>Experience :&nbsp; </p>
            <select name="experience" size="1">
                <option selected value="">Select...</option>
                <option value="Praise">Praise</option>
                <option value="Compliment">Compliment</option>
                <option value="New Client">New Client</option>
                <option value="Existing Client Maintenance">Existing Client Maintenance</option>
                <option value="Other">Other</option>
            </select>
        <br />

        <p>Message :&nbsp; </p><textarea name="message" rows="6" cols="25"></textarea>
        <br />
        <input type="submit" value="Send" />
        <input type="reset" value="Clear" />
    </form>

PHP

<?php
        $submitter_name = $_POST['submitter_name'];
        $name = $_POST['name'];
        $time = $_POST['time'];
        $date = $_POST['date'];
        $contact = $_POST['contact'];
        $phone = $_POST['phone'];
        $email = $_POST['email'];
        $source = $_POST['source'];
        $experience = $_POST['experience'];
        $message = $_POST['message'];


        $from_name = 'Form Name';
        $from = 'email@email.com';
        $to = 'email2@email.com';
        $subject = 'Subject';
        $semi_rand = md5(time());
        $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
        $headers = "From: ".$from .  "\r\nFrom: ".$from_name." <".$from.">\r\n";
        $headers .= "MIME-Version: 1.0\r\n" .
            "Content-Type: multipart/mixed;\r\n" .
            " boundary=\"{$mime_boundary}\"";
        $message_top = "This is a multi-part message in MIME format.\r\n" .
            "--{$mime_boundary}\r\n" .
            "Content-Type:text/html; charset=\"iso-8859-1\"\r\n" .
            "Content-Transfer-Encoding: 7bit\r\n";

            $email_message = "\n"."Submitter Name: $submitter_name<br />
                    Name: $name<br />
                    Time: $time<br />
                    Date: $date<br />
                    How was the contact made? $contact<br />
                    Phone: $phone<br />
                    Email: $email<br />
                    How did you hear about us? $source<br />
                    Experience: $experience<br />
                    Message: $message<br />";

        $email_message = stripslashes($email_message);
        $email_message = str_replace("\n","\r\n",$email_message);
        $email_message = $message_top . $email_message;

      mail($to, $subject, $email_message, $headers);
        echo "Thank You!" . " -" . "<a href='form.html' style='text-decoration:none;color:#ff0099;'> Go back</a>";

    //TO FILE
            $message = str_replace(",","",$message);
            $content = "\n$submitter_name,$name,$time,$date,$contact,$phone,$email,$source,$experience,$message";

            $f = fopen("lw_service_log.txt", "a");
            fwrite($f, $content);
            fclose($f);
?>
4

2 回答 2

0

我想通了,html中的选项值名称恰好与其他一些位具有相同的值。为他们创造独特的似乎可以解决这个问题。感谢所有的帮助!

于 2013-10-23T14:32:21.360 回答
0

这对我来说可以。检查代码中其他地方的变量是否覆盖了变量——我想你在粘贴之前已经剪掉了一些位。

于 2013-10-22T16:07:08.513 回答