PHP POST / Bootstrap表单

时间:2015-08-20 21:05:47

标签: php twitter-bootstrap

我没有收到来自我的电子邮件表单的电子邮件。 我创建了一个简单的表单,需要4个字段并将它们发送到我们的电子邮件。我测试了我的PHP代码没有错误。我仔细检查了html,看看脚本是否正确引用了它。我相信ids和名字是正确的。我还检查了我在php代码上创建的变量。我用谷歌搜索了所有我没想到的东西。谢谢!

var dump $ body显示

Thank you! One of our station representatives will contact you soon.
string(119) "

Name: TEST
Email: test@emaol.com
Station: 1234
Message:

我需要帮助。

FORM

    <form class="form-horizontal" role="form" method="post" action="feedback.php">
<fieldset>

<!-- Form Name -->
<legend>Our team will reach out to you as soon as possible.</legend>

<!-- Text input-->
<div class="control-group col-xs-4">
  <label class="control-label" for="textinput">Full Name</label>
  <div class="controls">
    <input id="name" name="name" placeholder="John Doe" class="input-xlarge" type="text">

  </div>
</div>

<!-- Text input-->
<div class="control-group col-xs-4">
  <label class="control-label" for="textinput">E-Mail</label>
  <div class="controls">
    <input id="email" name="email" placeholder="affiliate.marketing.app@123.com" class="input-xlarge" type="text">

  </div>
</div>

<!-- Text input-->
<div class="control-group col-xs-4">
  <label class="control-label" for="textinput">Station Code</label>
  <div class="controls">
    <input id="station" name="station" placeholder="xxx" class="input-xlarge" type="text">

  </div>
</div>


<!-- Textarea -->
<div class="control-group">
  <label class="control-label" for="textarea">Message</label>
  <div class="controls">                     
    <textarea id="message" name="message">I need help with....</textarea>
  </div>
</div>

<!-- Button -->
<div class="control-group">
  <label class="control-label" for="submit"></label>
  <div class="controls">
    <button type="submit" id="submit" value="Send" name="singlebutton" class="btn btn-primary">Submit</button>
  </div>
</div>

</fieldset>
</form>

PHP PAGE

        <?php

    /* These are the variable that tell the subject of the email and where the email will be sent.*/

    $emailSubject = 'Station App Support Request';
    $mailto = 'myemail@domain.com, myemail2@domain.com';

    /* These will gather what the user has typed into the fieled. */

    $nameField = $_POST['name'];
    $emailField = $_POST['email'];
    $stationField = $_POST['station'];
    $messageField = $_POST['message'];


    /* This takes the information and lines it up the way you want it to be sent in the email. */

    $body = <<<EOD
    <br><hr><br>
    Name: $nameField <br>
    Email: $emailField <br>
    Station: $stationField <br>
    Message: $messageField <br>

    EOD;

    $headers = "From: $emailField\r\n"; // This takes the email and displays it as who this email is from.
    $headers .= "Content-type: text/html\r\n"; // This tells the server to turn the coding into the text.
    $success = mail($mailto, $emailSubject, $body, $headers); // This tells the server what to send.

    ?>

0 个答案:

没有答案