Welcome Guest, Not a member yet? Register   Sign In
Transferring Variables
#1

[eluser]USCTrojans[/eluser]
Hello, I have searched the internet for several hours but can not seem to find an answer to this question. I am using Modular Extensions and am attempting to pass variables between functions in my "login" controller. For instance, I use a login controller to "post" the login information that a user inputs. I want to use one function to validate it and another function to send it to a mysql database if the CodeIgniter validation returns true.

Here is what my code looks like.

Code:
<?php

class Login extends MX_Controller
{

public function index()
{
  $this->load->view('loginform');
}

function validate_Login()
{
  $this->load->library('form_validation');
  $this->form_validation->set_rules('email_address', 'Email Address', 'trim|required|valid_email');
  $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[5]');
  
  if($this->form_validation->run() == FALSE)  
   {
    redirect('homepage'); //we need to figure out how to repopulate the form data here...
   }
  
  else
   {
   $login = array
    (
     'email_address' => strtolower($this->input->post('email_address')),
     'password' => md5($this->input->post('password'))
    );
   }

}

function welcome()
{
  //I want to access the $login array from the above function and use it here.

  }

}
?>




Theme © iAndrew 2016 - Forum software by © MyBB