表单输入后$ _POST变量为空

时间:2017-03-20 19:31:01

标签: php forms post

我正在尝试在php中开发一个简单的登录系统,在关注了一些新手教程后,我推出了这个解决方案:

html中的简单表单:

<form class = "form-horizontal" action = "{$BASE_URL}controllers/users/login.php" method = "POST">
                        <div class = "form-group">
                            <label for = "username" class = "col-sm-3 control-label">Username</label>
                            <div class = "col-sm-8">
                                <input type = "text" name = "username" class = "form-control" placeholder = "Username" required = "" autofocus = "" autocomplete = "off">
                            </div>
                        </div>

                        <div class = "form-group">
                            <label for = "password" class = "col-sm-3 control-label">Password</label>
                            <div class = "col-sm-8">
                                <input type = "password" name = "password" class = "form-control" placeholder = "Password" required = "" autocomplete = "off">
                            </div>
                        </div>

                        <div class = "form-group">
                            <div class = "col-sm-3 col-sm-offset-3">
                                <input type = "submit" class = "btn btn-primary" value = "Log In"></button>
                            </div>
                            <div class = "col-sm-5 text-right">
                                <a href = "" class = "small" data-toggle = "modal" data-target = "#forgotPassword"> Forgot Password?</a>
                            </div>
                        </div>
                    </form>

{$ BASE_URL}

$BASE_DIR = '/home/luiscosta/PhpstormProjects/LBAW-FEUP/';

然后在提交我的登录信息后,我在 login.php

上打印$ _POST变量
<?php

var_dump($_POST);

结果:

array(0) { }

我认为改变max_input_values的解决方案不会有任何区别,因为表单非常小且defaut值(1000)是可以接受的。

我还有一个config.php文件,其中包含了我认为与我的问题无关的Smarty库。

 <?php



include_once($BASE_DIR . 'lib/helpers/functions.php');
include_once($BASE_DIR . 'lib/helpers/Html.class.php');

include_once($BASE_DIR . 'lib/permissions/PagePermissions.class.php');
include_once($BASE_DIR . 'lib/permissions/Permission.class.php');
include_once($BASE_DIR . 'lib/permissions/AuthUser.class.php');
include_once($BASE_DIR . 'lib/permissions/GuestUser.class.php');
include_once($BASE_DIR . 'lib/permissions/AdminUser.class.php');
include_once($BASE_DIR . 'lib/permissions/ModUser.class.php');
include_once($BASE_DIR . 'lib/permissions/PagePermissions.class.php');
include_once($BASE_DIR . 'lib/permissions/ResourcePermission.class.php');

include_once ($BASE_DIR . '/lib/smarty/Smarty.class.php');


$smarty = new Smarty();
$smarty->template_dir = '../templates';
$smarty->compile_dir = '../templates_c';
$smarty->assign('BASE_URL', $BASE_URL);


$_SESSION['logged_in'] = isset($_SESSION['logged_in']) ? $_SESSION['logged_in'] : false;
$smarty->assign('LOGGED_IN', $_SESSION['logged_in']);

我不知道为什么POST变量被擦除。通过动作调用在$ POST数组中传递“names”形式,这看起来非常简单。 有没有人知道发生了什么?

此致

0 个答案:

没有答案