PHP联系表单不提交textarea

时间:2013-04-26 11:53:25

标签: php html contact-form

我曾尝试查看其他相关问题,我甚至向一些开发人员朋友寻求帮助,但没有任何帮助我修复我的联系表单。我有一个基本的PHP表单,但在提交时,我错过了电子邮件中的消息textarea字段。

表格代码:

<form action="sendContactForm.php" method="post">
                <div class="row">
                    <div class="small-12 large-12">
                        <div class="row formRow">
                            <div class="small-3 large-3 columns">
                                <label for="name" class="right inline">Name</label>
                            </div>
                            <div class="small-9 large-9 columns">
                                <input name="name" type="text" id="name" placeholder="Firstname Lastname">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="small-12 large-12">
                        <div class="row formRow">
                            <div class="small-3 large-3 columns">
                                <label for="email" class="right inline">Email</label>
                            </div>
                            <div class="small-9 large-9 columns">
                                <input name="email" type="text" id="email" placeholder="you@email.com">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="small-12 large-12">
                        <div class="row formRow">
                            <div class="small-3 large-3 columns">
                                <label for="company" class="right">Company Name</label>
                            </div>
                            <div class="small-9 large-9 columns">
                                <input name="company" type="text" id="company" placeholder="eg: Apple, Google, Microsoft">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="small-12 large-12">
                        <div class="row formRow">
                            <div class="small-3 large-3 columns">
                                <label for="description" class="right inline">Details</label>
                            </div>
                            <div class="small-9 large-9 columns">
                                <textarea name="description" id="description" placeholder="Please say a few words about why you are contacting me. If this is a project request, some good things to include are: project type, budget, deadline, and expected results."></textarea>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="small-12 large-12">
                        <div class="row formRow">
                            <div class="small-12 large-9 large-offset-3 columns">
                                  <input type="submit" name="submit" value="Submit" class="button expand"/>
                            </div>
                        </div>
                    </div>
                </div>
            </form>

PHP代码:

<?php
   // from the form
   $name = trim(strip_tags($_POST['name']));
   $email = trim(strip_tags($_POST['email']));
   $company = trim(strip_tags($_POST['company']));
   $message = $_POST['message'];
   $body = $name."\n".$company."\n".$message."\n";
   // set here
   $subject = "Contact form submitted!";
   $to = 'kempfjj@gmail.com';



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

   // send the email
   mail($to, $subject, $body, $headers);

   // redirect afterwords, if needed
   header('Location: index.html');

&GT;

我真的很感谢专业人士可以给我的任何帮助。

2 个答案:

答案 0 :(得分:1)

<textarea name="description" id="description"

让你使用不同的变量,改变

 $message = $_POST['message'];

进入

$message = $_POST['description'];

答案 1 :(得分:0)

您的PHP代码中有$message = $_POST['message'];,但表单上没有名称为message的输入元素,因此它将为空。

有一个名称为description的人,你没有在PHP中得到它。所以你的意思是:

$message = $_POST['description'];

或者您可以将表单上的输入元素上的name='description'更改为name='message'