PHP CodeIgniter 自定义登录表单


PHP CodeIgniter custom login form

我正在尝试使用PHP中的CodeIgniter创建一个登录表单。我已经实现了该功能,工作正常,但是我无法使用自定义样式表来设置我的样式。

这是我为登录视图准备的代码:

<!DOCTYPE html>
<html lang='en'>
    <head>
        <meta charset="UTF-8" /> 
        <title>
            DTI Manager
        </title>
        <link rel="stylesheet" type="text/css" href="/DTIManager/assets/css/style.css" />
    </head>
    <body>
        <div id="wrapper">
            <?php echo validation_errors();?>
            <?php $attributes = array('class' => 'LoginController', 'id' => 'login-form'); 
            echo form_open('LoginController/checkLogin', $attributes);?>
            <form name="login-form" class="login-form" action="" method="post">
                <div class="header">
                    <h1>Autentificare</h1>
                    <span>Pentru a accesa informatii despre comenzi transporturi trebuie sa fiti autentificat.</span>
                </div>
                <div class="content">
                    <input name="username" type="text" class="input username" placeholder="Utilizator" />
                    <div class="user-icon"></div>
                    <input name="password" type="password" class="input password" placeholder="Parola" />
                    <div class="pass-icon"></div>       
                </div>
                <div class="footer">
                    <input type="submit" name="submit" value="Login" class="button"/>
                </div>
            </form>
        </div>
        <div class="gradient"></div>

    </body>
</html>

这是我的登录控制器类:

class LoginController extends CI_Controller {
    function __construct() {
        parent::__construct();
    }
    public function index() {
        $this->load->view('login');
    }
    public function checkLogin() {
        $this->form_validation->set_rules('username', 'Utilizator', 'required');
        $this->form_validation->set_rules('password', 'Parola', 'required|callback_verifyUser');
        if ($this->form_validation->run() == false) {
            $this->load->view('login');
        } else {
            redirect('HomeController/index');
        }
    }
    public function verifyUser() {
        $name = $this->input->post('username');
        $pass = $this->input->post('password');
        $this->load->model('LoginModel');
        if ($this->LoginModel->login($name, $pass)) {
            return true;
        } else {
            $this->form_validation->set_message('verifyUser', 'Incorrect Email or Password. Please try again.');
            return false;
        }
    }
}

我尝试将属性添加到form_open函数中,即表单的ID,但没有成功,按钮和字段仍然没有相应地设置样式。

任何提示都非常感谢。

尝试在链接的 css 文件前面回显 base_url()。

 <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>DTIManager/assets/css/style.css" />

当然,如果您使用 .htaccess,则应使用适当的重写规则忽略项目中包含资产的文件夹。

 RewriteCond $1 !^(index'.php|DTIManager|assets|robots'.txt|error'.html)