Witam ponownie, przesyłam mój kod może z nim jest coś nie tak bo to dzieje się tylko gdy jest routing więc zapewne tam tkwi problem.
Plik controller
<?php
class Controller extends Database{
function model($param){
require_once('models/'.$param.'.php');
}
function view($param){
require_once('views/'.$param.'/'.'index.php');
}
function post($param){
}
}
}
function getUrl($url){
}
}
new Controller;
?>
controller login
<?php
class Login extends Controller {
function __model(){
$this->model('LoginModel');
$this->model = new LoginModel;
$this->session_start();
if( isset($_SESSION['admin']) ){ $this->getUrl('/admin'); exit(); } }
function __content(){
if($_POST){
$this->query('SELECT * FROM administratorzy WHERE login=:login AND password=PASSWORD(:password)');
$this->bind(':login', $this->post('login') );
$this->bind(':password', $this->post('password') );
$this->execute();
if($this->count() == 1 ){
$_SESSION['admin'] = true;
$this->getUrl('/admin'); exit(); }
else{ $this->error_login = $this->model->error_login($error); }
}
}
function __template(){
$this->view('Login');
}
}
?>
controller admin
<?php
class Admin extends Controller {
function __model(){
$this->model('AdminModel');
$this->model = new AdminModel;
$this->session_start();
}
function __content(){
if( !isset($_SESSION['admin']) && empty($_SESSION['admin']) ){ $this->getUrl('/'); exit(); }
}
function __template(){
$this->view('Admin');
}
}
?>
No i oczywiście routing
<?php
class Router{
function __construct(){
$this->rewrite = $_GET['page'];
$this->request = explode("/", $this->rewrite);
if( !empty($this->request[1
]) ){ header('Location: http://'.$_SERVER['HTTP_HOST']); }
else{
if( $this->request[0] == null){ $this->request[0] = 'login'; }
if( !file_exists('controllers/'.$this->request[0].'.php') ){ if( is_dir($this->request[0
]) ){ new Access;
}
require_once 'controllers/Found.php';
$this->controler = new Found;
$this->controler->__model();
$this->controler->__template();
}
else{
require_once 'controllers/'.$this->request[0].'.php' ;
$this->controler = new $this->request[0];
$this->controler->__model();
$this->controler->__content();
$this->controler->__template();
}
}
}
}
$router = new Router;
?>
Htaccess gdyby ktoś pytał
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
php_flag magic_quotes_gpc off
RewriteEngine on
RewriteRule ^([^./]{2}[^.]*)$ /index.php?page=$1 [QSA]