0
Good evening guys, I made a script for content management but when I put my data does not connect, just refreshes the page and stays in the same place, I put a command to error but not even that.
application views admin login.php:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Painel Administrativo</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.6 -->
<link rel="stylesheet" href="<?php echo base_url();?>assets/bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="<?php echo base_url();?>assets/dist/css/AdminLTE.min.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]-->
</head>
<body class="hold-transition login-page">
<div class="login-box">
<div class="login-logo">
<a href="#"><b>Painel</b> Administrativo</a>
</div>
<!-- /.login-logo -->
<div class="login-box-body">
<h4 class="login-box-message text-center">
<i class="fa fa-coffee green"></i>
Coloque suas informações abaixo para entrar
</h4>
<hr>
<?php $msg = $this->session->flashdata('messages'); ?>
<?php if(!empty($msg)): ?>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert">
<i class="icon fa fa-times"></i>
</button>
<?php echo $msg; ?>
</div>
<?php endif; ?>
<?php $info = $this->session->flashdata('info'); ?>
<?php if(!empty($info)): ?>
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert">
<i class="icon fa fa-times"></i>
</button>
<?php echo $info; ?>
</div>
<?php endif; ?>
<form method="post" action="<?php echo base_url(); ?>admin/auth/check_login" />
<div class="form-group has-feedback">
<input type="text" name="username" class="form-control" placeholder="Usuário" required autofocus>
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" name="password" class="form-control" placeholder="Senha" required>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<!-- /.col -->
<div class="col-xs-8"></div>
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat pull-right">Entrar</button>
</div>
<!-- /.col -->
</div>
</form>
<br>
<span class="text">Esqueceu a senha? <a href="<?php echo base_url(); ?>admin/reset_password">Clique aqui</a></span>
</div>
<!-- /.login-box-body -->
</div>
<!-- /.login-box -->
<!-- jQuery 2.2.3 -->
<script src="<?php echo base_url();?>assets/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="<?php echo base_url();?>assets/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
application controllers admin auth.php:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Auth extends CI_Controller
{
public function index()
{
if ($this->session->userdata('username') != "")
{
redirect('admin/home');
}
else
{
$this->load->view('admin/login');
}
}
public function login()
{
if ($this->session->userdata('username') != "")
{
redirect('admin/home');
}
else
{
$this->load->view('admin/login');
}
}
public function check_login()
{
$data = array(
'username' => $this->input->post('username', TRUE),
'password' => md5($this->input->post('password', TRUE))
);
$this->load->model('model_login');
$res = $this->model_login->check_user($data);
if ($res->num_rows() == 1)
{
foreach ($res->result() as $sess)
{
$sess_data['logged_in'] = 'Logged in';
$sess_data['username'] = $sess->username;
$sess_data['level'] = $sess->level;
$sess_data['status'] = $sess->status;
$this->session->sess_expiration = '1800'; //30 Minutes
$this->session->set_userdata($sess_data);
}
if ($this->session->userdata('level') == '0')
{
redirect('admin/home');
}
elseif ($this->session->userdata('level') == '1')
{
redirect('admin/home');
}
elseif (($this->session->userdata('status') == '1') && ($this->session->userdata('level') == '2'))
{
redirect('admin/home');
}
elseif (($this->session->userdata('status') == '2') && ($this->session->userdata('level') == '2'))
{
$this->session->set_flashdata('info', 'Sorry, your account is not active. Please contact the administrator.');
redirect('admin/auth');
}
}
else
{
$this->session->set_flashdata('info', 'Sorry, wrong username or password');
redirect('admin/auth');
}
}
}