我的PHP脚本随机无法读取post变量

时间:2013-07-15 20:16:57

标签: php html

我找不到它的模式,但是在我的验证码中,用于随机确认的PHP脚本将不会读取前面HTML表单中发布的$_POST变量。

<form name="post" action="post.php" method="post" enctype="multipart/form-data" style="text-align: center;"><br>

        <div style="position: relative; top: -5px;">Song Title: <input type="text" name="Title" pattern="[a-zA-Z0-9`\~\!\@\#\$\%\^\&\*\(\)\-\\\=\+\{\}\[\]]{2,40}" required></div><br>
            <input type="hidden" name="MAX_FILE_SIZE" value="20000000">

        <div style="position: relative; top: 5px; left: 34px;">Song File (Mp3 only): <input type="file" accept="audio/mpeg" name="Audio" id="file1" onchange="getChange()"></div><br><br><br>

        <div style="position: relative; top: -5px;"><img src="captcha/CaptchaSecurityImages.php"><br>Security Code:<br>
            <input name="security_code" type="text" required><br><br>

        <div style="position: relative; top: -8px;">
            <input type="submit" id="submit" disabled>
        </div>

</form>

表单填写完毕后,“提交”按钮即可启用。它工作正常。

阅读它的代码是: <?php echo $_POST['security_code'] ?>

它有时会起作用,而其他时候则不起作用。它经常说我没有在安全代码框中输入任何内容,即使我这样做了。我无法弄清楚为什么。

2 个答案:

答案 0 :(得分:3)

转储$_POST变量并查看结果如何

print_r($_POST);

你应该看到类似这样的结果

Array
(
    [security_code] => aaaa
    [MAX_FILE_SIZE] => 20000000
)

然后您就可以知道在随机性中何时无法读取$_POST数据

答案 1 :(得分:1)

我发现了问题。这是php.ini文件中的max_post_size。只要有什么东西超过它,它就不会发送任何$ _POST数据。