【发布时间】:2014-03-26 00:16:28
【问题描述】:
我以前使用过联系表格,但这个表格没有提交到我的电子邮件中。我也在尝试将重定向 URL 实现到 /contact.php
代码的问题是:我的电子邮件没有收到它。我的问题是:什么不允许联系表通过电子邮件?
<form id='contactus' action='index.php' method='post' accept-charset='UTF-8'>
<fieldset>
<div class="first-row">
<label for="name">Your Name</label>
<input type='text' class="input-large" name='name' id='name' value='' placeholder="Your Name" />
<label for="phone">Phone Number</label>
<input type='text' class="input-large" name='phone' id='phone' value='' placeholder="Phone Number" />
</div>
<div class="second-row">
<label for="email">Email Address</label>
<input type='text' class="input-large" name='email' id='email' value='' placeholder="Email Address" />
</div>
<div class="second-row">
<label for="business">Business</label>
<input type='text' class="input-large" name='business' id='business' value='' placeholder="Business" />
</div>
<label style="margin-left: 20px;" for="message">Message</label>
<textarea rows="10" class="input-xlarge" cols="50" name='message' placeholder="Message" id='message'></textarea>
<div class="clearfix"></div> /* Sorry I'm using Bootstrap */
<div><input type='submit' class="btn btn-primary" name='Submit' value='Submit' />
</div>
</fieldset>
</form>
<script type="text/php">
<?php
if(isset($_POST['submit'])) {
$to = "hello@geniusghost.com";
$subject = "Genius Ghost Contact Form";
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$business = $_POST['business'];
$message = $_POST['message'];
$body = "From: $name\n Phone Number: $phone\n E-Mail: $email\n Business: $business\n\n Message:\n $message";
mail($to, $subject, $body);
}
?>
</script>
帮帮我!我知道你们可能一直都有这些问题..
【问题讨论】:
-
将
name='Submit'更改为name='submit'变量和表单元素区分大小写。实际上,这更像是一个答案而不是评论。另外,去掉<script type="text/php">和</script> -
嗯嗯嗯,
<script type="text/php">?顺便说一下,你需要澄清你的问题,什么代码是什么文件的一部分? -
另外,你会有一个粗鲁的觉醒。让我们看看谁解决了这个问题; 我有。
-
更改了提交,但电子邮件本身仍未收到。我知道脚本类型很不稳定,但是之前它会使整个页面崩溃。它实际上在一个 .php 文件中。 index.php
-
See my answer, tested@Cee 完整的解释。
标签: php html forms twitter-bootstrap