【发布时间】:2011-11-22 05:06:04
【问题描述】:
我开始学习 php 和 mvc,这就是我想做的。我想创建一个简单的登录表单。 我的登录表单如下
<html>
<body>
<form action = "index.php" method = "post">
userName : <input type = "text" name = "username"/>
Password : <input type = "text" name = "password"/>
<br/>
<input type = "submit" value = "login" name = "btnlogin"/>
</form>
</body>
</html>
,我的模型和视图都设置好了,但是如何将这些信息传递给模型,我的控制器类如下
<?php
class controller
{
public $modelBook;
public $view;
public $modeluser;
function __construct()
{
$this->modelBook = new Book();
$this->view = new view();
$this->modeluser = new members();
$this->Home();
}
function Home()
{
$this->view->viewThis('login.php');
}
function login($username,$password)
{
$data = $this->modeluser->login($username, $password);
$this->view->viewThis('member.php',$data);
}
登录视图加载,但如何使用登录功能将表单中的数据获取到模型?
编辑:
我的 index.php
define ('SERVER_ROOT','C:\wamp\www\eclipse\MVCLMS');
define ('SITE_ROOT', 'http://localhost');
require_once 'controller/router.php';
?>
我的 router.php 文件
<?php
include 'model/modelBook.php';
include 'model/modelLogin.php';
include 'view/load.php';
include 'controller/controller.php';
$controller = new controller();
?>
【问题讨论】:
标签: php forms model-view-controller