2012-02-12 19 views
2

私はこのコントローラをテストしても$ user_dataを表示しません。なぜそうでないのか見ていない。他の人はいますか?私がしたいのは、入力をデータベース内のストアと一致させることです。配列が印刷されていません

コントローラー:

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 

class Activate extends CI_Controller 
{ 

public function __construct() 
{ 
    parent::__construct(); 
    $this->load->library('kow_auth');    
} 

public function index($param1 = NULL, $param2 = NULL) 
{ 
    //Config Defaults Start 
    $msgBoxMsgs = array();//msgType = dl, info, warn, note, msg 
    $cssPageAddons = '';//If you have extra CSS for this view append it here 
    $jsPageAddons = '<script src="http://www.kansasoutlawwrestling.com/kowmanager/assets/js/activatevalidate.js"></script>';//If you have extra JS for this view append it here 
    $metaAddons = '';//Sometimes there is a need for additional Meta Data such in the case of Facebook addon's 
    $siteTitle = '';//alter only if you need something other than the default for this view. 
    //Config Defaults Start 


    //examples of how to use the message box system (css not included). 
    //$msgBoxMsgs[] = array('msgType' => 'dl', 'theMsg' => 'This is a Blank Message Box...'); 

    /**********************************************************Your Coding Logic Here, Start*/ 

    $x = 0; 
    if(($param1 !== NULL)&&($param2 !== NULL)) 
    { 

     //params not null yay.. 
     if((isset($param1))&&((trim($param1) !== '')||(!empty($param1)))) 
     { 
      if(!is_numeric($param1)) 
      { 
       $x++; 
      } 
     } 
     if((isset($param2))&&((trim($param2) !== '')||(!empty($param2)))) 
     { 
      if(!preg_match('/^[A-Za-z0-9]+$/', $param2)) 
      { 
       $x++; 
      } 
     } 


     if($x !== 0) 
     { 
      $bodyContent = "error_page"; 
     } 
     else 
     { 
      $bodyContent = "activate_form"; 
     } 

    } 
    else 
    { 
     $bodyContent = "error_page"; 
    } 

    $bodyType = "full";//type of template 

    /***********************************************************Your Coding Logic Here, End*/ 

    //Double checks if any default variables have been changed, Start. 
    //If msgBoxMsgs array has anything in it, if so displays it in view, else does nothing.  
    if(count($msgBoxMsgs) !== 0) 
    { 
     $msgBoxes = $this->msgboxes->buildMsgBoxesOutput(array('display' => 'show', 'msgs' =>$msgBoxMsgs)); 
    } 
    else 
    { 
     $msgBoxes = array('display' => 'none'); 
    } 

    if($siteTitle == '') 
    { 
     $siteTitle = $this->metatags->SiteTitle(); //reads 
    } 

    //Double checks if any default variables have been changed, End. 

    $this->data['msgBoxes'] = $msgBoxes; 
    $this->data['cssPageAddons'] = $cssPageAddons;//if there is any additional CSS to add from above Variable this will send it to the view. 
    $this->data['jsPageAddons'] = $jsPageAddons;//if there is any addictional JS to add from the above variable this will send it to the view. 
    $this->data['metaAddons'] = $metaAddons;//if there is any addictional meta data to add from the above variable this will send it to the view. 
    $this->data['pageMetaTags'] = $this->metatags->MetaTags();//defaults can be changed via models/metatags.php 
    $this->data['siteTitle'] = $siteTitle;//defaults can be changed via models/metatags.php 
    $this->data['bodyType'] = $bodyType; 
    $this->data['bodyContent'] = $bodyContent; 
    $this->load->view('usermanagement/index', $this->data); 
} 

function activate_submit() 
{   
    $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|min_length[6]|max_length[12]|alpha_numeric'); 
    $this->form_validation->set_rules('user_id', 'User ID', 'trim|required|xss_clean|numeric'); 
    $this->form_validation->set_rules('registration_key', 'Registration Key', 'trim|required|xss_clean|alpha_numeric'); 

    if (!$this->form_validation->run()) 
    { 
     echo json_encode(array('error' => 'yes', 'message' => 'There was a problem submitting the form! Please refresh the window and try again!'));  
    } 
    else 
    {       
     if ($this->kow_auth->activate_user($this->input->post('user_id'), $this->input->post('registration_key'), $this->input->post('password'))) 
     { 
      echo json_encode(array('sucess' => 'yes', 'message' => 'Your account has been successfully activated!')); 
     } 
     else 
     {               
      echo json_encode(array('error' => 'yes', 'message' => 'The activation code you entered is incorrect or expired!')); 
     } 
    } 
} 

} 

/* End of file activate.php */ 
/* Location: ./application/controllers/activate.php */ 

図書館:誰もが、私はそれが配列をプリントアウトされていないと間違ってやって

function activate_user($user_id, $registration_key, $password) 
{ 
    $this->ci->users->purge_na(); 

    if ((strlen($user_id) > 0) AND (strlen($registration_key) > 0)) 
    { 
     $user_data = $this->ci->users->get_user_by_user_id($user_id); 
     print_r($user_data); 
     $genPassHash = $this->ci->genfunc->GenPassHash($password); 
     echo '<br />'; 
     print_r($genPassHash[0]); 

     if ($user_data['password'] == $genPassHash[0]) 
     { 
      return $this->ci->users->activate_user($user_id, $registration_key, $reGenFromPostPW[]); 
     } 
     else 
     { 
      return false;     
     } 
    } 
    else 
    { 
     return false; 
    } 
} 

を参照してくださいありません。

+0

あなたはどのコントローラの方法を実行していますか?どのデータを渡していますか?また、 '$ param1'と' $ param2'を呼び出さないでください。意味のある名前を付けてください。それがidを含んでいれば、 '$ id'と呼んでください。それにアクションが含まれている場合は、 '$ action'と呼んでください。どんなものであれ、 '$ param1'が何を期待しているのかを人々に伝えてください。 – Joe

+0

私は、フォームを送信するときにコントローラのactivate submit関数を呼び出しています。ここにフォームがあります:http://www.kansasoutlawwrestling.com/kowmanager/activate/10000/9f5b8139fdb9c50543cdf916eb38f686 –

+0

これはgenPassHash [0]を表示しますが、$ user_data配列変数の出力には気を付けません。 –

答えて

0

これはpurge_na関数に問題がありました。それはアクティブにする前にアクティブにしようとしているものを含めてユーザーを削除し続けました。

関連する問題