Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php HTML表单POST不发送值_Php_Html - Fatal编程技术网

Php HTML表单POST不发送值

Php HTML表单POST不发送值,php,html,Php,Html,我知道有几条这样的线索,我已经看过了,但似乎找不到答案。所以我有一个带有PHP文件操作和方法POST的HTML表单。表格如下: <div class="col-md-4 col-sm-12"> <div class="contact-form bottom"> <h2>Send a message</h2> <form id="main-contact-form" name="contact-form"

我知道有几条这样的线索,我已经看过了,但似乎找不到答案。所以我有一个带有PHP文件操作和方法POST的HTML表单。表格如下:

<div class="col-md-4 col-sm-12">
    <div class="contact-form bottom">
        <h2>Send a message</h2>
        <form id="main-contact-form" name="contact-form"  method="POST" action='http://creobox.ie/site/sendemail.php'>
            <div class="form-group">
                <input type="text" name="name" class="form-control" required="required" placeholder="Name">
            </div>
            <div class="form-group">
                <input type="email" name="email" class="form-control" required="required" placeholder="Email Id">
            </div>
            <div class="form-group">
                <textarea name="message" id="message" required="required" class="form-control" rows="8" placeholder="Your text here"></textarea>
            </div>                        
            <div class="form-group">
                <input type="submit" name="submit" class="btn btn-submit" value="Submit">
            </div>
        </form>
    </div>
</div>
代码的其余部分只是编写电子邮件等-这部分工作正常

我错过了一些非常简单的东西吗?代码看起来很好!我在$name、$from、$subject和$message上做了回显,我得到的只是

Details : <br/>

但这也不起作用。。。我只是在缓存索引页中得到了一个304-Not-Modified错误。这开始烧坏我的大脑了!我是否可以使用旧版本的jquery,从而产生所有问题

它正在工作,您必须没有在文本框中输入任何值。这是我获得的输出数组(4){[“name”]=>string(7)“fsafads”[“email”]=>string(14)”fsdaf@fads.com“[“message”]=>string(5)“sdfsa”[“submit”]=>string(6)“submit”}如果某个东西不能正常工作,第一个操作应该是删除函数调用前面的所有
@
符号。
@
符号抑制PHP为该调用抛出的任何错误,这使得查找错误变得更困难。@ArtleMaks,基于您的ajax示例。。。您有'var name=document.getElementById('name');`但是我在表单字段中没有看到任何
id=“name”
。其他字段也一样。此外,由于您提交了所有表单字段,因此可以在ajax调用中使用
数据:$(“#主联系人表单”).serialize()它正在工作您必须没有在文本框中输入任何值。这是我得到的输出数组(4){[“name”]=>string(7)“fsafads”[“email”]=>string(14)”fsdaf@fads.com“[“message”]=>string(5)“sdfsa”[“submit”]=>string(6)“submit”}如果某个东西不能正常工作,第一个操作应该是删除函数调用前面的所有
@
符号。
@
符号抑制PHP为该调用抛出的任何错误,这使得查找错误变得更困难。@ArtleMaks,基于您的ajax示例。。。您有'var name=document.getElementById('name');`但是我在表单字段中没有看到任何
id=“name”
。其他字段也一样。此外,由于您提交了所有表单字段,因此可以在ajax调用中使用
数据:$(“#主联系人表单”).serialize()
Details : <br/>
<div class="contact-form bottom">
                    <h2>Send a message</h2>
                    <form id="main-contact-form" name="contact-form">
                        <div class="form-group">
                            <input type="text" name="name" class="form-control" required="required" placeholder="Name">
                        </div>
                        <div class="form-group">
                            <input type="email" name="email" class="form-control" required="required" placeholder="Email Id">
                        </div>
                        <div class="form-group">
                            <textarea name="message" id="message" required="required" class="form-control" rows="8" placeholder="Your text here"></textarea>
                        </div>                        
                        <div class="form-group">
                            <input type="submit" name="submit" class="btn btn-submit" value="Submit" href="javascript: void(0);" onclick = "sendMail();">
                        </div>
                    </form>
                </div>
function sendMail()
{
    var name = document.getElementById('name');
    var email = document.getElementById('email');
    var message = document.getElementById('message');

        $.ajax({
            type: 'POST',
            url: 'sendemail.php',
            data: {
                'name' : name, 
                'email' : email, 
                'message' : message
            },
            success: function(json) { 
                if (json.status == 'S')
                    alert('Duplicates removed!');
                },
            error: function() {}
            });
}