*更新,似乎没有一个表格似乎正确发布。它们都加载任何指定的 URL,但没有可用的 POST 数据。
我的应用程序在本地 Lamp 上运行良好。一旦上传到我的实时服务器,登录表单将不起作用。我正在使用 CI3 和 Ion Auth 库。
我努力了
var_dump($_POST)
它总是输出以下内容:
array(0) {
}
因此,该表格似乎没有发布。我的表格:
<?php echo form_open("auth/login");?>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user"></i>
</span>
<?php echo form_input($identity);?>
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock"></i>
</span>
<?php echo form_input($password);?>
</div>
</div>
<button type="submit" class="btn btn-primary text-theme-xs mr-8">Login</button>
<?php echo form_checkbox('remember', '1', FALSE, 'id="remember"');?>
<a href="<?= site_url('auth/forgot_password') ?>" class="text-theme-xs pull-right a-black">Forgot your password ?</a>
</form>
到 URL 的帖子与显示表单的帖子相同,正如我所说,它在灯上运行良好。Firebug 显示有关密码字段和不安全站点的错误,但我认为这不会阻止表单发布?
我已经用 var_dump 替换了重定向,但没有任何反应,问题是没有发送 _POST 数据。
控制器:
function login()
{
$this->data['title'] = "Login";
//validate form input
$this->form_validation->set_rules('identity', 'Identity', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run() == true)
{
//check to see if the user is logging in
//check for "remember me"
$remember = (bool) $this->input->post('remember');
if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember))
{
//if the login is successful
//redirect them back to the home page
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect('/', 'refresh');
}
else
{
//if the login was un-successful
//redirect them back to the login page
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect('auth/login', 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries
}
}
else
{
//the user is not logging in so display the login page
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->data['identity'] = array('name' => 'identity',
'id' => 'identity',
'type' => 'text',
'class' => 'form-control',
'value' => $this->form_validation->set_value('identity'),
'placeholder' => 'Username',
);
$this->data['password'] = array('name' => 'password',
'id' => 'password',
'type' => 'password',
'class' => 'form-control',
'placeholder' => 'Password',
);
$this->_render_page('templates/head', $this->data);
$this->_render_page('templates/navbar', $this->data);
$this->_render_page('auth/login', $this->data);
$this->_render_page('templates/footer', $this->data);
}
}
abiove 控制器/视图的 html 输出:
<form action="http://www.mydomain.uk/auth/login" method="post" accept-charset="utf-8">
<p>
<label for="identity">Email/Username:</label> <input type="text" name="identity" value="" id="identity" class="form-control" placeholder="Username" />
</p>
<p>
<label for="password">Password:</label> <input type="password" name="password" value="" id="password" class="form-control" placeholder="Password" />
</p>
<p>
<label for="remember">Remember Me:</label> <input type="checkbox" name="remember" value="1" id="remember" />
</p>
<p><input type="submit" name="submit" value="Login" />
</p>
</form>