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 8930631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:55:58+00:00 2026-06-15T08:55:58+00:00

I am trying to use a variable in my controller that has been created

  • 0

I am trying to use a variable in my controller that has been created in my model.

Here is the model:

public function validate_retrieve($data) {

            $query = $this->db->where($data)->get('users', '1');

            foreach ($query->result() as $user)
            {
                $user->email;
                $user->salt;
                $user->id;

            }

            $token = sha1($user->email.$user->salt).dechex($user->id);
            $reset_token = array(
                'token' => $token,
                'email' => $user->email
            );

            $insert = $this->db->insert('reset', $reset_token, '1');
            return $reset_token;
        }

and on my controller I’m trying to use $token that was created in the model:

public function retrieve()
        // REQUEST PASSWORD RESET
        // LOADED WHEN THE FORM IS SUBMITTED OFF THE PASSWORD PAGE AND SENDS THE EMAIL WITH TOKEN AND INSTRUCTIONS
        {
            $this->load->library('form_validation');
            $this->load->library('session');
            $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
            $this->load->model('user_model', 'um');
            $this->load->library('encrypt');
            $this->load->helper('url');
            $submit = $this->input->post('submit');
            $salt = $this->_salt();

            if($submit)
            // IF THE SUBMIT BUTTON IS SET
            {

                // START PROCESS TO CREATE $USER VARIABLE THAT HOLDS WHAT THE USER ENTERED IN THE FORM AND THAT CAN GET CHECKED AGAINST THE DB IN THE MODEL
                $user = $this->um->validate_retrieve(array('email' => $this->input->post('email')));


                // IF THE USER IS CREATED AND CHECKS OUT AND ALL OF THE ERRORS ARE CLEARED ON THE FORM
                if( $user && $this->form_validation->run() == TRUE ) {

                    $domain = "clci.dev/index.php";

                    // CREATE A TOKEN LINK TO SEND TO THE USERS EMAIL THAT EXIST IN THE DB AND WAS ENTERED

                    $token = $this->um->token;
                    $link = "http://www.".$domain."/auth/reset/?token=$token";


                        $this->load->library('email');

                        $this->email->from('noreply@cysticlife.org', 'CysticLife');
                        $this->email->to($this->input->post('email')); 

                        $this->email->subject('Reset Password');
                        $this->email->message("Please go to the following web address to reset your password:\n\n$link\n\n-Your friends at CysticLife\n\nPlease remember to add the cysticlife.org domain to your address book to ensure that you receive your CysticLife e-Notifications as requested.");  

                        $this->email->send();
                        redirect('auth/success');
                        exit;

                    }
                    $this->form_validation->run() == FALSE;
                    $data['main_content'] = 'auth/password';
                    $this->load->view('includes/templates/main_page_template', $data);
                    $data['email_error'] = 'This email is invalid';
                }
            }

thanks in advance

  • 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-06-15T08:55:59+00:00Added an answer on June 15, 2026 at 8:55 am

    You’re trying to access an array as an object.

    $reset_token = $this->um->validate_retrieve($whatever_id);
    $token = $reset_token['token'];
    

    That’s how you access the token portion of the returned results from this function.

    And according to your latest update, you would actually access it like this:

    $token = $user['token'];
    

    Because in the following line you assign the results of the validate_retrieve method to the variable $user:

    $user = $this->um->validate_retrieve(array('email' => $this->input->post('email')));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use variable in different function, I want to set global
I am trying to use a variable to get a function in a extended
I'm trying to use usort() and leverage a global variable inside its function scope,
SOLVED! I`m trying save data from array in variable. I have in controller: $data
have a Grails domain object that has a custom static function to grab data
I created an ApplicationController.cs that all other Controllers inherit. I'm trying to use this
I'm trying to use my variable in all files of my program. this is
I am trying to use Unicode variable names in g++, but it does not
I'm a newbie to PHP/SQL and I am trying to use a variable within
I'm trying to use a global variable. I've declared it as global to begin

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.