首页 文章

隐藏类型输入值未在php中传递

提问于
浏览
6

我有一个联系表格,它有一个非常简单的验证码系统,例如“太阳热或冷吗?”用户进入热门 . 我在type =“hidden”字段中包含原始问题和答案以下处理表单 .

问题是这些输入字段在以下php页面上始终为空白 . 这是我在联系表格上的代码:

<form id="contact-form" name="contact-form" method="POST" onsubmit="return true;" action="submit.php">
    <fieldset>
        [...]Removed For Convenience[...]
        <label class="captcha" id="captcha" name="captcha">
            <span style="color:#FFFFFF">Is the sun hot or cold?</span>
            <input type="text" value="hot" name="answer" id="answer">
            <input type="hidden" value="Is the sun hot or cold?" name="realquestion" id="realquestion">
                <input type="hidden" value="hot" name="realanswer" id="realanswer">
            <p>Please answer as simply as possible; hot, cold, z, etc. (This question is for security purposes)</p>
        </label><br>
    <div class="clear-form"></div>
        <div class="buttons-wrapper">
            <input id="button-2" type="submit" value="Submit">
        </div>
    </fieldset>
</form>

在接下来的页面中,submit.php我把它放在最顶层的“print_r($ _ POST);”这是返回的数组:

Array ( [Name] => asasasas [Email] => My.Email@gmail.com [contactTime] => Best Time To Contact You? [Phone] => Phone: [Account] => Account: [OS] => [Department] => [Message] => Message: [answer] => hot [realquestion] => [realanswer] => )

现在是踢球者,如果在我的联系页面上,我将type =“hidden”更改为type =“text”这两个字段,其他任何代码都无效 . 一旦完成,我可以将其更改回type =“hidden”,它将继续为该会话工作 . 如果我切换浏览器,重新启动浏览器,或转到另一台计算机,它将返回到无法读取这些隐藏的输入字段 .

有没有人遇到这个或知道可能会发生什么?我不知所措 . 我真的想弄清楚这个问题,而不是使用像javascript验证这样的解决方法,我已经这样做但我希望php检查到位,以防他们有javascript关闭(我假设我们已经获得的机器人垃圾邮件有它关闭) .

2 回答

  • 0

    通过改变解决了问题

    <input type="hidden" value="Is the sun hot or cold?" name="realquestion" id="realquestion">
                <input type="hidden" value="hot" name="realanswer" id="realanswer">
    

    <input type="hidden" value="Is the sun hot or cold?" name="realquestion" id="realquestion" **/>**
                <input type="hidden" value="hot" name="realanswer" id="realanswer" **/>**
    

    而不是被浏览器缓存绊倒 .

  • 13
    $realAns = $_POST['realanswer'];
    echo ($realAns);
    

    为我捕获隐藏的字段值 .

相关问题