Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7602645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:27:54+00:00 2026-05-30T23:27:54+00:00

Updated: RJZ: TdjxQetc is the $activateCode that comes from the DB so when I

  • 0

Updated:

RJZ:

TdjxQetc is the $activateCode that comes from the DB so when I run /confirm/ I should be getting Sorry you did not have a correct Activation Code as I am not passing in any var ($activateCode) but when I run /confirm/$activateCode I should get Thanks your account is now active you may login! and with the else statement

I am thinking that it should be changed and a new model function developed to check if userActive has been set to 1 and then display another $message so that the link can only be used.


View:

<div class = "messages">
    <?php if($confirmMessage != ''): ?>
        <?php if($confirmError): ?>
            <p class="error">
                <?php echo $confirmMessage; ?>
                </p>
                <?php else: ?>
                    <p class="message">
                        <?php $confirmMessage?>
                        </p>
                        <?php endif; ?>
                        <?php endif; ?>
    </div>

Controller:

function confirm(){

        $activateCode = $this->uri->segment(3);
        $error = FALSE;
        $message = '';

        if($activateCode == '')
        {
            $error = TRUE;
            $message = 'Sorry you did not have a correct Activation Code.';
        }
            $userConfirmed = $this->users_model->confirm_user($activateCode);

            if($userConfirmed){
                $message = 'Thanks your account is now active you may login!';
            }else{
                $error = TRUE;
                $message = 'I am sorry we do not have any details with that Activation Code';
            }
            $data['companyName'] = $this->core_model->companyDetails()->coreCompanyName;
            $data['pageTitle'] = "User Confirm";
            $data['confirmError'] = $error;
            $data['confirmMessage'] = $message;
            $this->load->view('frontend/assets/header', $data);
            $this->load->view('frontend/user_confirm', $data);
            $this->load->view('frontend/assets/footer');
    }

I am unsure why I am not getting the validation messages, I just get my view. The database is updating to 1.

View:

<h1><?php echo $companyName; echo nbs(1);?> - <?php echo $pageTitle; ?></h1>

    <p>Error: <?php echo validation_errors();?></p>

Controller:

function confirm(){

        $activateCode = $this->uri->segment(3);

        if($activateCode == '')
        {
            $this->form_validation->set_message('userConfirmError', 'Sorry you did not have a correct Activation Code.');
        }
            $userConfirmed = $this->users_model->confirm_user($activateCode);

            if($userConfirmed){
                $this->form_validation->set_message('userConfirmed', 'Thanks your account is now active you may login!');
            }else{
                $this->form_validation->set_message('userRecord', 'I am sorry we do not have any details with that Activation Code');
            }
            $data['companyName'] = $this->core_model->companyDetails()->coreCompanyName;
            $data['pageTitle'] = "User Confirm";
            $this->load->view('frontend/assets/header', $data);
            $this->load->view('frontend/user_confirm', $data);
            $this->load->view('frontend/assets/footer');
    }

Confirm Function:

function confirm_user($activateCode)
    {
     //Selects the userID where the given URI activateCode = ?

        $this->db->select('userID');
        $this->db->from('users');
        $this->db->where('userActiveCode', $activateCode);

        $result = $this->db->get();

        if($result->num_rows == 1)  // If the above result is = 1 then update the userActive row else it will fail
        {
            $this->db->set('userActive', 1);
            $this->db->where('userActiveCode', $activateCode);

            return TRUE;
        }else{
            return FALSE;
        }

Core Model:

function companyDetails()
    {
        static $details;

        if(!$details)
        {
            $this->db->select('coreCompanyName, coreContactName, coreContactEmail');
            $details = $this->db->get('core')->first_row();
        }
        return $details;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:27:55+00:00Added an answer on May 30, 2026 at 11:27 pm

    You are kind of making a mountain out of a mole hill here Jess. Let’s see what we can do to clean this up:

    Controller Method

    function confirm()
    {
        $activate_code = $this->uri->segment(3);
    
        if(!$this->users_model->confirm_user($activate_code))
            $error = true;
        else
            $error = false;
    
        $data['companyName'] = $this->core_model->companyDetails()->coreCompanyName;
        $data['pageTitle'] = "User Confirm";
        $data['confirmError'] = $error;
        $this->load->view('frontend/assets/header', $data);
        $this->load->view('frontend/user_confirm', $data);
        $this->load->view('frontend/assets/footer');
    }
    

    View

    <div class = "messages">
        <?php if($confirmError): ?>
            <p class="error">
                Your activation code is invalid.
            </p>
        <?php else: ?>
             <p class="message">
                Your account has been activated.
             </p>
        <?php endif; ?>
    </div>
    

    Please add this code to the top of your UserModel::confirm_user method:

    if($activateCode == '')
       return false;
    

    I’ve simplified your controller method to only two cases — success or error. There is no need to check activate_code because your model is doing that for you.

    In addition, I prefer to keep strings that are only used in views where they belong — in the view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[Updated a bit] I have a Task model that has a :completed boolean attribute.
Updated to be clear. Step One: I have a XML file that I want
Updated : Originally I didn't realize this only fails when run from unit tests.
****UPDATED**** I have a custom ContentActionInvoker that has some crazy logic in it. I'd
updated question I want to highlight weeks of the datepicker that have the sum
UPDATED: I realise now that I've been misreading the diff, and I have a
UPDATED QUESTION Since the ctor is not supported by .NETCF (public FileStream(IntPtr handle, FileAccess
----------Updated ------------ codymanix and moonshadow have been a big help thus far. I was
Updated: The actual resolution that the compile box which served my compile request was
Updated: please see this other thread instead, all this COM stuff is not part

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.