我自己创建了一个MVC框架。我陷入了网址更新的困境。这是我尝试登录时发生的情况:
$这 - >负载>查看(配置文件);
执行上面一行代码后,网址保持不变 localhost / Login_Controller /
有人能告诉我如何解决它吗?
我从本教程中获得了设计MVC的帮助。 MVC Tutorial that i studied
应用/ router.php
class router{
private $registry;
public function __construct($registry){
$this->registry = $registry;
}
public function getController(){
$url = $_GET['url'];
if($contoller_path){
include $controller_path; // if controller exits the path will be included
$url = new $url.Controller(); // instantiating the object for controller
$url->auth_login();
}
}
}
控制器/ Login_controller.php
class Login_controller extends controller{
public function __construct($registry){
parent::_construct( $registry);
}
public function auth_login(){
$url = $_GET['url'];
$username = $_POST['username'];
$password = $_POST['password'];
if($model_path){
include $_path;
$this->registry->url = new $url.model();
$status = $this->registry->{url->auth_login}($username, $password);
if($status == 'success'){
//HERE....
// I want to change the url localhost/login_controller to localhost/profile/
$this->registry->template->show('profile');
}if($status == 'failure'){
$this->registry->template->show('index');
}
}
}
}
模型/ aut_login_hmodel
class auth_login_model extends model{
public function __construct($registry){
parent::_construct( $registry);
}
public function auth_login($username, $password){
//here is the code to query db and all..
if($success){
return $success;
}else{
return $failure;
}
}
}
应用/的template.php
class template{
private $registry;
public function __construct($registry){
$this->registry = $registry;
}
public function show($view){
if(is_readable($view_path)){
include $view_path; // if view exists, it would load
}else{
include $index_path; // if view does not exists, index page loads
}
}
}
希望这足以详细阐述。