1

当用户在我们的页面上注册时,我希望在用户单击提交后出现一个页面,它会说“感谢您注册,请检查您的电子邮件。”。

这是我添加功能的代码

function add(){
        $this->set('title_for_layout', 'Please Login');
        $this->set('stylesheet_used', 'style');
        $this->set('image_used', 'eBOXLogo.jpg');   
    if($this->request->is('post')){
    $this->User->create(); 
    if ($this->User->save($this->request->data)) 
    { 
        $this->Session->setFlash('The user has been saved');  

    }
    else { $this->Session->setFlash('The user could not be saved. Please, try again.'); } 
    } 

  } 

这是我的添加视图

<h2>Please enter your details</h2>
<?php
echo $this->Form->create('User', array('action'=>'add'));
echo $this->Form->input('username',array('label'=>'Username: '));
echo $this->Form->input('password',array('label'=>'Password: '));
echo $this->Form->input('password_confirmation',array('type'=>'password'));
echo $this->Form->input('email',array('label'=>'Email: '));
echo $this->Form->input('title',array('label'=>'Title: '));
echo $this->Form->input('firstname',array('label'=>'First Name: '));
echo $this->Form->input('surname',array('label'=>'Surname: '));
echo $this->Form->input('street',array('label'=>'Street Address: '));
echo $this->Form->input('city',array('label'=>'City: '));
echo $this->Form->input('state',array('label'=>'State: '));
echo $this->Form->input('country',array('label'=>'Country: '));
echo $this->Form->end('Click here to Register ');

?>
4

1 回答 1

2
if ($this->User->save($this->request->data)) { 
    $this->Session->setFlash('The user has been saved');
    $this->redirect(array('action' => 'thank_you'));
}

或者:

if ($this->User->save($this->request->data)) { 
    $this->Session->setFlash('The user has been saved');
    $this->render('thank_you');
}

换句话说,只需创建另一个您重定向到的操作,或者在用户注册时简单地呈现一个特殊视图。

于 2012-05-23T03:48:01.700 回答