Я новичок в Code-igniter и пытаюсь создать форму входа в систему с сеансом. Я застрял в точке, где поле имени пользователя и пароля пустое, чем в нем не отображается CSS.
iисследуйте немного больше об этом и обнаружите, что когда я впервые открываю свою форму project_login в этот момент, ссылка на css выглядит следующим образом: localhost / ci_project / assets / bower_components / bootstrap / dist / css / mystyle.css
после нажатия накнопка входа в систему, когда имя пользователя и пароль в этот момент пусты, ссылка css выглядит следующим образом (Auth - мой контроллер, где я написал функцию входа в систему) localhost / ci_project / Auth / assets / bower_components / bootstrap / dist / css / mystyle.css
login.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>AdminLTE 2 | Log in</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="<?php base_url()?>assets/bower_components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="<?php base_url()?>assets/bower_components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="<?php base_url()?>assets/bower_components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="<?php base_url()?>assets/dist/css/AdminLTE.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="<?php base_url()?>assets/plugins/iCheck/square/blue.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition login-page">
<div class="login-box">
<div class="login-logo">
<a href="<?php echo base_url(); ?>"><b>VEMS</b> ER</a>
</div>
<!-- /.login-logo -->
<div class="login-box-body">
<h4><p class="login-box-msg">VEMS ENGINEERING MULTI SERVICE</p></h4>
<form action="<?php echo base_url()?>Auth/login_validation" method="post">
<div class="form-group has-feedback">
<input type="username" name="username" class="form-control" placeholder="Email">
<span class="text-danger"><?php echo form_error('username'); ?></span>
</div>
<div class="form-group has-feedback">
<input type="password" name="password" class="form-control" placeholder="Password">
<span class="text-danger"><?php echo form_error('password'); ?></span>
</div>
<div class="row">
<?php echo $this->session->flashdata("error"); ?>
<div class="col-xs-8">
<div class="checkbox icheck">
<label>
<input type="checkbox" class="login-check" checked="checked"> Remember Me
</label>
</div>
</div>
<!-- /.col -->
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat">Sign In</button>
</div>
<!-- /.col -->
</div>
</form>
<!-- <div class="social-auth-links text-center">
<p>- OR -</p>
<a href="#" class="btn btn-block btn-social btn-facebook btn-flat"><i class="fa fa-facebook"></i> Sign in using
Facebook</a>
<a href="#" class="btn btn-block btn-social btn-google btn-flat"> Sign in using
Google+</a>
</div> -->
<!-- /.social-auth-links -->
<a href="#">I forgot my password</a><br>
<!-- <a href="register.html" class="text-center">Register a new membership</a> -->
</div>
<!-- /.login-box-body -->
</div>
<!-- /.login-box -->
<!-- jQuery 3 -->
<script src="<?php base_url()?>assets/bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="<?php base_url()?>assets/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="<?php base_url()?>assets/plugins/iCheck/icheck.min.js"></script>
<script>
$(function () {
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' /* optional */
});
});
</script>
</body>
</html>
Auth.php (Controller)
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Auth extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->helper('url');
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->model('Auth_model');
}
public function index(){
$this->load->view('pages/login');
}
public function login_validation(){
$this->load->library('form_validation');
$data['title'] = "Login";
$this->form_validation->set_rules('username', 'Username', 'trim|required|valid_email');
$this->form_validation->set_rules('password', 'Password', 'required');
if($this->form_validation->run()){
//get value from login form by post method
$username = $this->input->post('username'); //email
$username = $this->input->post('password'); //password
//model function
$this->load->model('Auth_model');
if($this->Auth_model->can_login($username, $password)){
$session_data = array(
'username' => $username
);
$this->session->set_userdata($session_data);
redirect(base_url(). 'Auth/enter');
}
else{
$this->session->set_flashdata('error', 'Invalid Username Or password');
redirect(base_url(). 'Auth');
}
}
else{
$this->load->view('pages/login');
}
}
public function enter(){
if($this->session->userdata('username') != ''){
echo "<h2>Welcome".$this->session->userdata('username')."</h2>";
echo '<a href="'.base_url().'Auth/logout>LOGOUT</a>';
}
else{
redirect(base_url(). 'Auth');
}
}
public function logout(){
$this->session->session_destroy();
redirect('pages/login');
}
}
$config['base_url'] = 'http://localhost/ci_project/'
;