PHP联系表单功能

时间:2016-06-04 17:06:54

标签: php

$from = "from@domain.com";
    $to =  "myemail@email";
    $subject ="Contact Form";
    $message ="<p>Item Name: $itemname.</p>
    <p>Brand: $brandname.</p>
    <p>Description: $description.</p>
    <p>Availability: $availability.</p>
    <p>Contact Person: $contact</p>
    <p>Email: $email</p>
    <p>Location: $location</p>
    ";

      $boundary =  md5(time());
        //header
        $headers = "MIME-Version: 1.0\r\n"; 
        $headers .= "From:".$from."\r\n"; 
        $headers .= "Reply-To: ".$from."" . "\r\n";
        $headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n"; 

        //plain text 

        $body = "--$boundary\r\n";
        $body .= "Content-Transfer-Encoding: 7bit"."\r\n\r\n";
        $body .= "This is a MIME encoded message."."\r\n";

        $body = "--$boundary\r\n";
        $body .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        $body .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; 
        $body .= $message ."\r\n"; 

        //attachment
        $body .= "--$boundary\r\n";
        $body .="Content-Type: application/octet-stream; name=\"$file_name\"\r\n";

        $body .="Content-Transfer-Encoding: base64\r\n";
        $body .="Content-Disposition: attachment; filename=\"$file_name\"\r\n\r\n";

        $body .= $encoded_content ."\r\n";


        if (@mail( $to, $subject, $body, $headers)) {
        $resultMessage = '<div class="alert alert-success">Thank You. Your message has been sent</div>';
    } else {
            $resultMessage = '<div class="alert alert-danger">Sorry Please Try Again.</div>';
    }
 }

这是我的PHP代码。它由我的登录用户使用,因此用户通常通过选择用户名&gt;电子邮件&gt;密码进行注册并注册然后他们登录并查看此联系表单。所以我想在提交表单时,PHP应该发送他们的用户名和电子邮件。我怎么能这样做?

0 个答案:

没有答案