提交后$ _POST数据为空

时间:2017-06-08 04:29:19

标签: php html post

我在下面的html中有一个联系表格:

<form id="contactForm" action="http://voicemarketing.cmctelecom.vn/php/contact-form.php" method="POST">
<div class="row">
    <div class="form-group">
        <div class="col-md-6">
            <label>Your Name *</label>
            <input type="text" value="" data-msg-required="Please enter your name." maxlength="100" class="form-control" name="name" id="name" required>
        </div>
        <div class="col-md-6">
            <label>Your Company Name *</label>
            <input type="text" value="" data-msg-required="Please enter your company name." maxlength="100" class="form-control" name="companyname" id="companyname" required>
        </div>
    </div>
</div>
<div class="row">
    <div class="form-group">
        <div class="col-md-6">
            <label>Your phone number *</label>
            <input type="number" value="" data-msg-required="Please enter your phone number." maxlength="12" class="form-control" name="phonenumber" id="phonenumber" required>
        </div>
        <div class="col-md-6">
            <label>Your email address *</label>
            <input type="email" value="" data-msg-required="Please enter your email address." data-msg-email="Please enter a valid email address." maxlength="100" class="form-control" name="email" id="email" required>
        </div>
    </div>
</div>
<div class="row">
    <div class="form-group">
        <div class="col-md-12">
            <label>Message *</label>
            <textarea maxlength="5000" data-msg-required="Please enter your message." rows="10" class="form-control" name="message" id="message" required></textarea>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-md-12">
        <input type="submit" value="Send Message" class="btn btn-primary btn-lg mb-xlg" data-loading-text="Loading...">
    </div>
</div>

我试图通过$ _POST获得价值

$fields = array(
0 => array(
    'text' => 'Name',
    'val' => $_POST['name']
),
1 => array(
    'text' => 'Email address',
    'val' => $_POST['email']

),
2 => array(
    'text' => 'Message',
    'val' => $_POST['message']

),
3 => array(
    'text' => 'Company',
    'val' => $_POST['companyname']
),
4 => array(
    'text' => 'Phone Number',
    'val' => $_POST['phonenumber']
));

像往常一样,我把$ _POST ['形式的名字'] 但只有姓名,电子邮件,消息正在运作 和公司名称,phonenumber什么都不返回。 我真的无法弄清楚问题是什么

3 个答案:

答案 0 :(得分:0)

确保您的数据库设置正确,有时您可能会尝试将文本放在“int”类型行中,这将导致此类问题。值得一试。

答案 1 :(得分:0)

首先在顶部声明你的POST变量,并确保name属性与POST VARIABLES相同。

答案 2 :(得分:0)

关闭代码的html部分,并将电话号码的类型设置为文本。

<form>.....</form>