-3

我曾尝试查看其他相关问题,甚至向一些开发者朋友寻求帮助,但没有任何东西可以帮助我修复我的联系表。我有一个基本的 PHP 表单,但在提交时,我缺少电子邮件中的消息文本区域字段。

表格代码:

<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');

?>

我非常感谢专业人士在这方面能给我的任何帮助。

4

2 回答 2

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

在让您使用不同的变量时,请更改

 $message = $_POST['message'];

进入

$message = $_POST['description'];
于 2013-04-26T11:57:32.880 回答
0

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

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

$message = $_POST['description'];

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

于 2013-04-26T11:56:24.073 回答