0

質問はインデックス関数の内部にあり、2つの変数を取得し、それらを使用してデータベースに対して値をチェックし、レコードと一致するかどうかを確認し、一致する場合は電子メールからのアクティブ化を検証する関数を実行します。ここのメッセージで何をすべきかを理解しようとしています。私がやりたいのは、アクティベーションが成功したことを示す特定のメッセージと、同じページの読み込みでアクティベーションが成功しなかったことを示すメッセージを表示することです。これはどのように試みるべきですか?

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

class Activate extends CI_Controller { 

public function __construct()
{
    parent::__construct();
    $this->load->library('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 =  '';//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 = $this->config->item('defaultTemplate') ."error_page";
        }
        else
        {
           $bodyContent = $this->config->item('defaultTemplate') ."/usermanagement/forms/activate";//which view file
        }

    }
    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['siteTitle'] = $siteTitle;//defaults can be changed via models/metatags.php
    $this->data['bodyType'] = $bodyType;
    $this->data['bodyContent'] = $bodyContent;
    $this->load->view($this->config->item('defaultTemplate') .'/usermanagement/index', $this->data);
}

}

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

編集 :

両方のパラメーターを取得してデータベースと照合する関数を実行する必要がある場所を見つけようとしています。結果がtrueを返した場合は、ユーザーが検証します。

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

class Activate extends CI_Controller { 

public function __construct()
{
    parent::__construct();
    $this->load->library('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 =  '';//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 = $this->config->item('defaultTemplate') ."error_page";
           $message = 'User was not activated successfully! Please try again with the right credentials!';
        }
        else
        {
           $bodyContent = $this->config->item('defaultTemplate') ."/usermanagement/forms/activate";//which view file
           $message = 'User was activated successfully! You may now login!';
        }

    }
    else
    {
        $bodyContent = "error_page";
    }
    $this->data['message'] = $message;
    $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['siteTitle'] = $siteTitle;//defaults can be changed via models/metatags.php
    $this->data['bodyType'] = $bodyType;
    $this->data['bodyContent'] = $bodyContent;
    $this->load->view($this->config->item('defaultTemplate') .'/usermanagement/index', $this->data);
}

}

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

何か案は?

4

1 に答える 1

1

あなたは使用しようとすることができます$this->session->flashdata()

于 2012-05-23T09:45:12.763 に答える