表单值未获取

时间:2015-06-05 06:52:13

标签: php forms email

这是一个联系表单,当我点击提交按钮时,我收到了邮件,但未提取表单值。我无法找到问题所在。有人能帮我吗?

这里我包含了我的代码:

<?php
header('Content-type: application/json');
$status = array(
    'type'=>'success',
    'message'=>'Email sent!'
);

$name = @trim(stripslashes($_POST['fn'])); 
$email = @trim(stripslashes($_POST['ln'])); 
$subject = @trim(stripslashes($_POST['email'])); 
$message = @trim(stripslashes($_POST['message'])); 
$sub = 'mail from xxxx.com';
$email_from = $subject;
$email_to = 'xxxx@gmail.com';

$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;

$success = @mail($email_to, $sub, $body, 'From: <'.$email_from.'>');

echo json_encode($status);
die;
?>
<form id="main-contact-form" class="contact-form" name="contact-form" action="send.php" method="post"">
              <div class="row-fluid">
                <div class="span5">
                    <label>First Name</label>
                    <input type="text" name="fn" class="input-block-level" required="required" placeholder="Your First Name">
                    <label>Last Name</label>
                    <input type="text" name="ln" class="input-block-level" required="required" placeholder="Your Last Name">
                    <label>Email Address</label>
                    <input type="text" name="email" class="input-block-level" required="required" placeholder="Your email address">
                </div>
                <div class="span7">
                    <label>Message</label>
                    <textarea name="message" id="message" required="required" class="input-block-level" rows="8"></textarea>
                </div>

            </div>
            <input type="submit" >
            <p> </p>

        </form>

1 个答案:

答案 0 :(得分:0)

我可以用愚蠢的错误来解决这个问题......

<form id="main-contact-form" class="contact-form" name="contact-form" action="send.php" method="post"">

在这一行我可以给出如此改变

<form id="main-contact-form" class="contact-form" name="contact-form" action="send.php" method="post">