提交后未设置php $ _POST []

时间:2019-03-09 20:04:13

标签: php post

我已经检查了所有表格动作和方法,都正确。我真的很奇怪为什么会这样。我使用了很多次,这次我找不到任何错误。当我调试$ _POST ['name']和所有其他数组内容时,它表明没有设置任何值,全部为'NULL'。

HTML:

<form class="contact2-form validate-form" method="post" action="index.php">
    <span class="contact2-form-title">
            Contact Us
    </span>

    <div class="wrap-input2 validate-input" data-validate="Name is required">
        <input class="input2" type="text" name="name">
        <span class="focus-input2" data-placeholder="NAME"></span>
    </div>

    <div class="wrap-input2 validate-input" data-validate = "Valid email is required: ex@abc.xyz">
        <input class="input2" type="text" name="email">
        <span class="focus-input2" data-placeholder="EMAIL"></span>
    </div>

    <div class="wrap-input2 validate-input" data-validate = "Message is required">
        <textarea class="input2" name="message"></textarea>
        <span class="focus-input2" data-placeholder="MESSAGE"></span>
    </div>
    <div class="wrap-input2 validate-input" data-validate = "Input the answer">
        <input class="input2" type="text" name="validator">
        <span class="focus-input2" data-placeholder="8 + ? = 17"></span>
    </div>
    <input class="input2" type="hidden" name="domain" value="ywsample.com">
    <div class="container-contact2-form-btn">
        <div class="wrap-contact2-form-btn">
            <div class="contact2-form-bgbtn"></div>
            <input type="submit" name="submit_request" value="Send Request" class="contact2-form-btn">
        </div>
    </div>
</form>

PHP:

if (isset($_POST['submit_request'])) {
        if ($_POST['validator'] == "9") {
            $date = date('Y-m-d H:i:s');
            $success = sendAdminEmail($date);
        } 
        else {
            $redo = "Your validation answer is not correct";
        }
    }
    else {
        $redo = "Something went wrong, please try again later.";
    }

完整的代码位于txt文件中。我无法将其粘贴到此处,发生许多显示错误。 https://www.ynw.com.au/ynw-demo/contact/index.txt 您可以直接复制文件并将文件扩展名更改为php进行测试。

0 个答案:

没有答案