联系电子邮件命令不起作用

时间:2014-05-02 07:38:46

标签: php jquery html email

我的联系方式有问题。

一般功能: -

  1. html表单中的四个文件
  2. 当有人点击Sumbit时,它会向所提到的电子邮件ID
  3. 发送一封电子邮件
  4. 还向总结该表格的客户发送确认
  5. 问题: - 当有人点击sumbit时,php只发送确认邮件而不是发送表格

    请在下面找到我的代码

    HTML代码

    <form class="user-info-from-cookie contact-form" action="email.php" method="post" id="contact-site-form" accept-charset="UTF-8">
        <div>
            <div class="form-item form-group form-type-textfield form-item-name">
                <label for="edit-name">Your name <span class="form-required" title="This field is required.">*</span></label>
                <input class="form-control form-text required" type="text" id="edit-name" name="name" value="" size="60" maxlength="255" />
            </div>
            <div class="form-item form-group form-type-textfield form-item-mail">
                <label for="edit-mail">Your e-mail address <span class="form-required" title="This field is required.">*</span></label>
                <input class="form-control form-text required" type="text" id="edit-mail" name="mail" value="" size="60" maxlength="255" />
            </div>
            <div class="form-item form-group form-type-textfield form-item-subject">
                <label for="edit-subject">Subject <span class="form-required" title="This field is required.">*</span></label>
                <input class="form-control form-text required" type="text" id="edit-subject" name="subject" value="" size="60" maxlength="255" />
            </div>
            <div class="form-item form-group form-type-textarea form-item-message">
                <label for="edit-message">Message <span class="form-required" title="This field is required.">*</span></label>
                <div class="form-textarea-wrapper">
                    <textarea class="form-control form-textarea required" id="edit-message" name="message" cols="60" rows="5"></textarea>
                </div>
            </div>
            <input type="hidden" name="form_build_id" value="form-F8mZPLk2E0pbtFIWV65KihLnCu4VuSZI0Mxf_M93uPk" />
            <input type="hidden" name="form_id" value="contact_site_form" />
            <div class="form-actions form-wrapper" id="edit-actions">
                <input class="btn btn-primary btn-sm form-submit" type="submit" id="edit-submit" name="op" value="Send message" />
            </div>
        </div>
    </form>
    

    PHP代码

    <?php
    $to = "info@YourCompany.com";
    $from = $_REQUEST['mail'];
    $name = $_REQUEST['name'];
    $headers = "From: $from";
    $subject = "Website Inquiry";
    
    $fields = array();
    $fields{"name"} = "Name";
    $fields{"mail"} = "Email";
    $fields{"subject"} = "Subject";
    $fields{"message"} = "Message";
    
    $body = "We have received the following information:\n\n";
    foreach ($fields as $a => $b) {
        $body .= sprintf("%20s: %s\n", $b, $_REQUEST[$a]);
    }
    
    $headers2 = "From: info@YourCompany.com";
    $subject2 = "YourCompany.com - Thank you for contacting us";
    $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 12 hours. If you have any more questions, please consult our website at www.YourCompany.com";
    
    if ($from == '') {
        print "You have not entered an email, please go back and try again";
    } else {
        if ($name == '') {
            print "You have not entered a name, please go back and try again";
        } else {
            $send = mail($to, $subject, $body, $headers);
            $send2 = mail($from, $subject2, $autoreply, $headers2);
            if ($send) {
                header("Location: http://www.YourCompany.com");
            } else {
                print "We encountered an error sending your mail, please notify webmaster@YourCompany.com";
            }
        }
    }
    ?> 
    

    请帮忙

0 个答案:

没有答案
相关问题