PHP $ _POST无效

时间:2017-06-22 07:49:36

标签: php html5 post echo isset

尝试方法获取和$_GET它完美无缺但当我尝试方法发布时$_POST$_REQUEST没有任何反应= \任何帮助?感谢

PHP和FORM在SAME PAGE

HTML:

<form method="post">
    <div class="form-group">
        <label for="user">Meno:</label>
        <input type="text" id="user" name="user" class="form-control" placeholder="meno admina" required>
    </div>
    <div class="form-group">
        <label for="psw">Heslo:</label>
        <input type="password" id="psw" name="password" class="form-control" placeholder="heslo admina" required>
    </div>
    <div class="form-group">
        <input type="submit" class="btn btn-success" name="submit" v>
    </div>
</form>

PHP:

<?php
if (isset($_POST["submit"])) {
    $user = htmlspecialchars(strip_tags($_POST['user']));   
    echo $user;
}
?>

还尝试回复$_POST['user'];,但没有。

2 个答案:

答案 0 :(得分:1)

编辑:

对于所有遇到同样问题的人,关于这一行:

<form method="post"> - 帖子必须以大写字母书写,例如:

<form method="POST"> - 这解决了这个问题。

答案 1 :(得分:0)

<?php print_r($_POST); ?>

并在表单标记中设置表单action