控制器未调用操作

发布于 2024-12-26 01:23:23 字数 2750 浏览 4 评论 0原文

我在应用程序/控制器中有一个控制器名称 UserController ,

基本文件夹是 zend-login 并且有 3 个子文件夹 1= 应用程序 2 = 库 3=web_root 问题就在这里!!当我点击 http://localhost/zend_login/web_root/user/loginhttp://localhost/zend_login/web_root/user/register 我收到此错误错误 404 未找到对象!这两个文件都在一个文件夹中

<?php
require_once 'Zend/Controller/Action.php';
class UserController extends Zend_Controller_Action{
public function indexAction(){
$this->view->assign('name', 'xainee');
$this->view->assign('title', 'Hello');
}
public function loginAction(){
$request = $this->getRequest();  
$this->view->assign('action', $request->getParam());  
$this->view->assign('title', 'Login Form');
$this->view->assign('username', 'User Name');   
$this->view->assign('password', 'Password');
}

public function registerAction(){
$request = $this->getRequest();
$this->view->assign('action',"process");
$this->view->assign('title','Member Registration');
$this->view->assign('label_fname','First Name');
$this->view->assign('label_lname','Last Name'); 
$this->view->assign('label_uname','User Name'); 
$this->view->assign('label_pass','Password');
$this->view->assign('label_submit','Register');     
$this->view->assign('description','Please enter this form completely:');
}
}
 ?>


action for this is here views/scripts/user/register.phtml and 
views/scripts/user/login.phtml 
this is register.phtml

<?php include "header.phtml"; ?>
<h1><?=$this->escape($this->title);?></h1>
<div id="description">
<?=$this->escape($this->description);?>
 </div>
<form name="register" method="post" action="<?=$this->escape($this->action)?>">
<table>
<tr>
 <td><?=$this->escape($this->label_fname)?></td>
 <td><input type="text" name="first_name"></td>
</tr>
<tr>
<td><?=$this->escape($this->label_lname)?></td>
<td><input type="text" name="last_name"></td>
</tr>   
<tr>
<td><?=$this->escape($this->label_uname)?></td>
<td><input type="text" name="user_name"></td>
</tr>   
<tr>
<td><?=$this->escape($this->label_pass)?></td>
<td><input type="password" name="password"></td>
</tr>   
</table>
<input type="submit" name="submit" value="<?=$this->escape($this->label_submit);?>">
</form>
<?php include "footer.phtml"; ?>

i have a controller name UserController in application/controllers

the base folder is zend-login and there are 3 sub folder 1= application 2 = library 3=web_root
problem is here!! when ever i hit http://localhost/zend_login/web_root/user/login or http://localhost/zend_login/web_root/user/register
i get this error Error 404 Object not found! both the file are there in a folder

<?php
require_once 'Zend/Controller/Action.php';
class UserController extends Zend_Controller_Action{
public function indexAction(){
$this->view->assign('name', 'xainee');
$this->view->assign('title', 'Hello');
}
public function loginAction(){
$request = $this->getRequest();  
$this->view->assign('action', $request->getParam());  
$this->view->assign('title', 'Login Form');
$this->view->assign('username', 'User Name');   
$this->view->assign('password', 'Password');
}

public function registerAction(){
$request = $this->getRequest();
$this->view->assign('action',"process");
$this->view->assign('title','Member Registration');
$this->view->assign('label_fname','First Name');
$this->view->assign('label_lname','Last Name'); 
$this->view->assign('label_uname','User Name'); 
$this->view->assign('label_pass','Password');
$this->view->assign('label_submit','Register');     
$this->view->assign('description','Please enter this form completely:');
}
}
 ?>


action for this is here views/scripts/user/register.phtml and 
views/scripts/user/login.phtml 
this is register.phtml

<?php include "header.phtml"; ?>
<h1><?=$this->escape($this->title);?></h1>
<div id="description">
<?=$this->escape($this->description);?>
 </div>
<form name="register" method="post" action="<?=$this->escape($this->action)?>">
<table>
<tr>
 <td><?=$this->escape($this->label_fname)?></td>
 <td><input type="text" name="first_name"></td>
</tr>
<tr>
<td><?=$this->escape($this->label_lname)?></td>
<td><input type="text" name="last_name"></td>
</tr>   
<tr>
<td><?=$this->escape($this->label_uname)?></td>
<td><input type="text" name="user_name"></td>
</tr>   
<tr>
<td><?=$this->escape($this->label_pass)?></td>
<td><input type="password" name="password"></td>
</tr>   
</table>
<input type="submit" name="submit" value="<?=$this->escape($this->label_submit);?>">
</form>
<?php include "footer.phtml"; ?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

再可℃爱ぅ一点好了 2025-01-02 01:23:23

推荐的 .htaccess 是
RewriteEngine 开启
RewriteCond %{REQUEST_FILENAME} -s [或]
RewriteCond %{REQUEST_FILENAME} -l [或]
RewriteCond %{REQUEST_FILENAME} -d
重写规则 ^.*$ - [NC,L]
RewriteRule ^.*$index.php [NC,L]

recommended .htaccess is
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文