2011-09-16 102 views
0

我正在嘗試僅使用Auth組件查看學生的進度報告。對於所有其他鏈接,不需要認證。討論板上我已經有了一個單獨的論壇插件。cakephp:註冊頁面上的註冊鏈接不工作

當用戶點擊導航欄上的進度報告鏈接時,用戶被定向到/ merry_parents/register。在這裏,新用戶將點擊註冊鏈接,現有用戶將點擊登錄鏈接。

但是,我的註冊鏈接不起作用。當我點擊註冊時,我沒有被引導到註冊頁面。我究竟做錯了什麼?任何幫助深表感謝。

下面是我的代碼:

register.ctp

<?php 
    echo $this->Html->link('Sign Up','/merry_parents/signup').' for new user |'.$this->Html->link('Login','/merry_parents/login',array()).' for existing user'; 
    ?> 

merry_parents_controller.php

<?php 
    class MerryParentsController extends AppController{ 

var $name='MerryParents'; 
var $components=array('Auth','Session'); 

function beforeFilter(){ 
    //$this->Auth->authorize='actions'; 
    $this->Auth->loginAction=array('controller'=>'merry_parents','action'=>'register'); 
    //$this->Auth->loginRedirect=array('controller'=>'merry_parents','action'=>'report_card'); 

} 

function register(){ 

} 

function login(){ 
} 

function logout(){ 
} 

function signup(){ 
    if (!empty($this->data)){ 
     //$this->Auth->password($this->data['MerryParent']['password2'] used to get what the hashed password2 would look like. 
     if ($this->data['MerryParent']['password']==$this->Auth->password($this->data['MerryParent']['password2'])){ 

       $merryparent_id=$this->MerryParent->field('id', 
               array('MerryParent.name'=>$this->data['MerryParent']['name'], 
               'MerryParent.email'=>$this->data['MerryParent']['email']) 
               ); 
       echo $merryparent_id; 

       print_r($this->data); 
       if ($this->MerryParent->save($this->data))//record with $merryparent_id is updated 
        { 
        $this->Session->setFlash('You will be receiving an email shortly confirming your login and password.'); 
        $this->Auth->login($this->data); //automatically logs a user in after registration 
        $this->redirect(array('controller'=>'pages','action'=>'home')); 
        } 
       else 
        echo $this->Session->setFlash(__('Your admission could not be saved, please try again!',true)); 


      }//end if ($this->data['MerryParent']['password'].... 
      else 
       echo $this->Session->setFlash('Typed passwords did not match'); 
    }//end if (!empty($this->data)) 
} 
} 
?> 
+0

你指示在哪裏呢? –

回答