Когда вы звоните http://localhost/login, откроется страница входа.Когда вы вводите данные и нажимаете «Отправить», они перенаправляются на http://localhost/loginuser, но больше ничего не происходит.Нет перенаправления на приборную панель, ничего не происходит.И я спрашиваю себя, почему?У кого-нибудь есть идеи?
login_view.php:
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Photography</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz" crossorigin="anonymous">
<link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/pure-min.css" integrity="sha384-nn4HPE8lTHyVtfCBi5yW9d20FjT8BJwUXyWZT9InLYax14RDjBj46LmSztkmNP9w" crossorigin="anonymous">
<link rel="stylesheet" href="<?php echo base_url('assets/css/style.css');?>">
</head>
<body>
<div id="bgimglogin">
<div class="centered">
<i class="fas fa-sign-in-alt loginicon"></i>
<?php if(isset($_SESSION)) {
echo $this->session->flashdata('flash_data');
} ?>
<form id="loginform" class="pure-form pure-form-stacked" method="POST">
<fieldset>
<label for="username">Username</label>
<input id="username" type="text" placeholder="max_mustermann">
<label for="password">Passwort</label>
<input id="password" type="password" placeholder="Passwort">
<button type="submit" class="pure-button pure-button-primary">Anmelden</button>
</fieldset>
</form>
<p id="register"><a href="<?php echo site_url("register"); ?>">Registrieren</a></p>
</div>
<footer>
<p>© <?php echo date("Y"); ?> by Photography</p>
</footer>
</div>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous">
</script>
<script>
$("#loginform").submit(function(event){
event.preventDefault();
$.ajax({
type:"POST",
url: "<?php echo base_url(); ?>loginuser",
data:$("#submitform").serialize(),
dataType: "text",
success: function (response) {
window.location.replace("<?php echo base_url(); ?>loginuser")
}
})
})
</script>
</body>
</html>
login_controller.php:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class login_controller extends CI_Controller {
function __construct(){
parent::__construct();
$this->load->model('login_model');
}
public function index(){
if($_POST){
$result = $this->login_model->pruefe_user($_POST);
if(!empty($result)){
$data = array(
'id_user' => $result->id,
'username' => $result->username
);
$this->session->set_userdata($data);
redirect('dashboard');
}
else{
$this->session->set_flashdata('flash_data', 'Passwort oder Name falsch');
redirect('login');
}
}
$this->load->view('website/login_view');
}
}
login_model.php:
<?php
class login_model extends CI_Model {
public function __construct(){
$this->load->database();
}
public function pruefe_user($data){
$this->db->where('username', $data['username']);
$this->db->where('password', md5($data['password']));
$result = $this->db->get('user')->row();
return $result;
}
}
rout.php:
$route['default_controller'] = 'index_controller/index';
$route['login'] = 'index_controller/login';
$route['register'] = 'index_controller/register';
$route['ref'] = 'index_controller/ref';
$route['contact'] = 'index_controller/contact';
$route['imprint'] = 'index_controller/imprint';
$route['dashboard'] = 'index_controller/dashboard';
$route['loginuser'] = 'login_controller/index';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;