gpt4 book ai didi

zend-framework - Zend 框架路由/重定向

转载 作者:行者123 更新时间:2023-12-04 18:22:09 25 4
gpt4 key购买 nike

我试图在用户注册后将用户重定向到注册页面,但它没有这样做..

<?php

class RegisterController extends Zend_Controller_Action
{

public function init()
{
/* Initialize action controller here */
}

public function indexAction()
{
$form = new Application_Form_Register();
$form->submit->setLabel('Register');
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$first_name = $form->getValue('first_name');
$surname = $form->getValue('surname');
$email = $form->getValue('email');
$username = $form->getValue('username');
$password = $form->getValue('password');
$is_admin = $form->getValue('is_admin');
$age = $form->getValue('age');
$gender = $form->getValue('gender');
$uni = $form->getValue('uni');
$register = new Application_Model_DbTable_Users();
$register->addUser($first_name, $surname, $email, $username, $password, $is_admin, $age, $gender, $uni);

} else {
$form->populate($formData);
}
$route = array('controller'=>'Register', 'action'=>'registered');
$this->_helper->redirector->gotoRoute($route);

}
}

public function registeredAction()
{
// action body
}

}

这就是我所拥有的

谢谢

最佳答案

在 Controller 中,您可以执行以下操作:

$this->_redirect('/controller/action');

关于zend-framework - Zend 框架路由/重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10435981/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com