Welcome Guest, Not a member yet? Register   Sign In
Custom Routes with Account Verify Controller
#1

[eluser]xtremer360[/eluser]
I've been at this for a few days and have tried working with my routes and code to make this work but for some reason I just can't find the correct solution.

After a user registers they are sent an email with a link to the activate account page where the user must enter their password into a form field and submit the form so that it takes the user_id and registration key and password and tries to activate the account.

What I would like to see happen is when the user only puts in kansasoutlawwrestling.com/kowmanager/activate OR kansasoutlawwrestling.com/activate/whateverUserID it gives the error page as it should AND when they put in kansasoutlawwrestling.com/activate/whateverUserID/whateverRegistrationKey it shows the activate page.

I tried echoing out the param variables but all they did was echo $1 and $2.

My url looks like this: kansasoutlawwrestling.com/kowmanager/activate/10000(user_id)/4ku08daf8fd90df8098f0da(registration_key)

My custom route is as follows:

Code:
$route['activate/:num/:any'] = "activate/index/$1/$2";

My activate controller is as follows:

Code:
<?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 = '[removed][removed]';//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*/
  
        $this->error = FALSE;

        if(NULL != $param1 AND NULL != $param2)
        {
           if(!is_numeric($param1) OR (!is_string($param2) AND trim($param2) != ''))
           {
             $this->error = TRUE;
           }
        }
        else
        {
          $this->error = TRUE;
        }
        
        $bodyContent = $this->error? 'error_page' : 'activate_form';


        
        
  $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);
}

    
}

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

#2

[eluser]CroNiX[/eluser]
The manual for route talks about (:any) and (:num), but you are using :any and :num.
#3

[eluser]xtremer360[/eluser]
Yes thank you I finally noticed that however I'm still getting a problem when their is only the userid such as the page here http://www.kansasoutlawwrestling.com/kow...ate/10000/ BUT its the same code on all the pages because it uses the same templating system.
#4

[eluser]xtremer360[/eluser]
Any other ideas?
#5

[eluser]CroNiX[/eluser]
Maybe try this (in this order):
Code:
$route['activate/(:num)/(:any)'] = "activate/index/$1/$2";
$route['activate/(:num)'] = "activate/index/$1";
$route['activate'] = "activate";

First line of your index() method:
Code:
if (is_null($param1) OR is_null($param2))  //if either is still null, error out
{
  $this->load->view('error_view');
}
else
{
  //rest...
}




Theme © iAndrew 2016 - Forum software by © MyBB