韩顺平 php视频教程 笔记心得 zend.framework.第16讲.综合应用-购物车2
2012-07-31 10:46 java环境变量 阅读(230) 评论(0) 编辑 收藏 举报1 创建一个空的zf项目
2 相关配置
applicaton.ini
apache虚拟目录配置
#购物车
NameVirtualHost *
<VirtualHost *:80>
DocumentRoot "F:/xampp/htdocs/shopping/public"
ServerName ebey.com
# This should be omitted in the production environment
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
去掉indexController当中没必要的文件
即可跳转正常。
<?php
require_once 'BaseController.php';
require_once APPLICATION_PATH.'/models/Users.php';
/*
* 该控制器专门用于响应登录和退出
*/
class LoginController extends BaseController
{
public function loginAction()
{
//调用表模型
$userModel=new Users();
//获取用户id和密码
$id=$this->getRequest()->getParam("id","");
$pwd=$this->getRequest()->getParam("pwd","");
$db=$userModel->getAdapter();
$where=$db->quoteInto("id=?", $id)
.$db->quoteInto(" AND pwd=?", md5($pwd));
$loginuser=$userModel->fetchAll($where)->toArray();
if(count($loginuser)==1){
//取出这个用户的信息保存到session中
session_start();
$_SESSION['loginuser']=$loginuser;
$this->_forward('gohallui','hall');
}else{
//失败
$this->view->err="<font color='red'>您的用户名和密码错误</font>";
$this->_forward('index','index');
}
}
}
<?php
require_once 'BaseController.php';
require_once APPLICATION_PATH.'/models/Book.php';
/*
* 该控制器专门用于响应登录和退出
*/
class HallController extends BaseController
{
public function gohalluiAction()
{
/* echo 'ok';
exit();*/
$bookModel=new Books();
$this->view->books=$bookModel->fetchAll()->toArray();
session_start();
$this->view->loginuser=$_SESSION['loginuser'][0];
$this->render('hall');
/*echo 'okadsfasf';
exit();*/
}
}