【问题标题】:Html contact form and phpHtml 联系表格和 php
【发布时间】:2015-06-17 05:41:19
【问题描述】:

我将发布我的 html 表单和我的 php,希望有人可以帮助我使它们真正起作用。我的议程是让用户在 html 中输入的内容发送到我的电子邮件中,并让他们收到一封回信,说我们收到了他们的电子邮件。

我还希望用户在点击提交后被发送到“谢谢我们收到您的电子邮件”页面。 html 有点长,请见谅。

    <!-- contact --->

<div class="templatemo_caption">
     <div class="clear"></div>
                <p>Create any task you would like.</p>
                <div class="clear">
                    </div>
                    <div align="center">
     <div class="container">
    <div class="row">
      <div class="col-md-3">
          <form action="sendmail.php" method="POST">
        <form role="form">
          <div class="form-group">

            <input name="name" type="text" class="form-control" id="name"   placeholder="Your Name" maxlength="30">
          </div>
          <div class="form-group">
             <input name="email" type="text" class="form-control" id="email"       placeholder="Your Email" maxlength="30">
          </div>
          <div class="form-group">
            <input name="subject" type="text" class="form-control"        id="subject" placeholder="Your Task" maxlength="40">
          </div>
              <br />&nbsp;<br />
          <input type="submit" value="Send Feedback" />



      </div>
      <div class="col-md-9">
        <div class="txtarea">
          <textarea name="subject" rows="10" class="form-control" id="subject"> Any specific details we need to know?</textarea>
        </div>



          </form>
           </form>
      </div>
    </div>
  </div>

<!--Contact End-->

PHP 看起来像这样

<?php

/* Subject and email variables */

$emailsSubject = 'This is where you type what you subject will show up as';
$webMaster  = 'chelsieoverbay@yahoo.com';


/* Gathering Data Variables - Whats in the form */

$name = $_POST ['name'];
$email = $_POST ['email'];
$subject = $_POST ['subject'];
$msg = $_POST['msg'];


/*Security*/




/* What You Want To See In The Email Place Inbetween $body = <<<EOD  and      EOD; */    
$body = <<<EOD

<strong>Client:</strong> $name
<br />
<br />
<strong>Email:</strong> $email
<br />
<br />
<strong>Subject:</strong> $subject
<br />
<br />
______________________________________________
   <br />
   <br />
   $msg

   EOD;

   /* Headers is a tag containing the users email and how you want it to display in your email */

  $headers = "From: $email\r\n";
 $headers .= "Content-type: text/html\r\n";

/* This is what sends the email */
$success = mail($webMaster, $emailsSubject, $body, $headers);

/* Results Rendered as Html */
echo file_get_contents("studenthome.nku.edu/~overbayc1/onlinebutler/submit.html");

?>

【问题讨论】:

  • 请澄清您的问题。如果我们不知道您在问什么,我们无能为力!

标签: php html email contact-form


【解决方案1】:

这是一个示例,说明如何发送两条消息,一条给您的处方,一条给您自己。

//MESSAGE TO RECIEPENT ************************************************/
        // multiple recipients
        $to  = $_POST["email"];

        // subject
        $subject = 'Your mail has been recieved';

        // message
        $message = '
    <html>
    <head>
      <title>Your mail has been recieved</title>
    </head>
        <body style="margin: 0px;">
            <p style="margin-bottom: 35px;">Dear '.$_POST["name"].',</p>
            <p style="margin-bottom: 5px;">
Your email with the subject: '.$con_subject.' has been recived, you will be answered as soon as possible, possibly within the last 5 days.
            </p>
            <p>
- AthaxDesigns
            </p>
        </body>
    </html>
    ';

        // To send HTML mail, the Content-type header must be set
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

        // Additional headers
        $headers .= 'To: '.$_POST["email"] . "\r\n";
        $headers .= 'From: AthaxDesigns <noreply@athaxdesigns.com>' . "\r\n";

        // Mail it
        mail($to, $subject, $message, $headers);



//MESSAGE TO MYSELF ************************************************/

        // multiple recipients
        $to  = "support@athaxdesigns.com";

        // subject
        $subject = 'You have recieved an mail from '.$_POST["name"].' Subject: '.$con_subject.' ';

        // message
        $message = '
    <html>
    <head>
      <title>You have recieved an mail from '.$_POST["name"].'</title>
    </head>
        <body style="margin: 0px;">
            <p style="margin-bottom: 35px;">Name: '.$_POST["name"].' Email: '.$_POST["email"].',</p>
            <p style="margin-bottom: 5px;">
                '.$_POST["subject"].'
            </p>
            <p style="margin-bottom: 5px;">
                '.$_POST["content"].'
            </p>
        </body>
    </html>
    ';

        // To send HTML mail, the Content-type header must be set
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

        // Additional headers
        $headers .= 'To: ' . $to . "\r\n";
        $headers .= 'From: '.$_POST["name"].' <'.$to.'> '. "\r\n";
        $headers .= 'Reply-To: ' . "\r\n" .

        // Mail it
        mail($to, $subject, $message, $headers);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-28
    • 1970-01-01
    • 1970-01-01
    • 2019-09-04
    • 1970-01-01
    相关资源
    最近更新 更多