[eluser]Mark K[/eluser]
I am very sorry but I'm still confused. Let's have an example. Let's say I want to create a login widget (which is a module).
View:
Code:
<?php
echo form_open(base_url() . 'login/widget');
echo form_label('Email: ', 'txt_email');
$data = array(
'name' => 'txt_email',
'id' => 'txt_email',
'type' => 'text',
'placeholder' => 'Enter email address',
'autocomplete' => 'off',
'maxlength' => '24'
);
echo form_input($data);
echo '<br>';
echo form_label('Password: ', 'txt_password');
$data = array(
'name' => 'txt_password',
'id' => 'txt_password',
'type' => 'password',
'placeholder' => 'Enter password',
'autocomplete' => 'off',
'maxlength' => '16'
);
echo form_input($data);
echo '<br>';
echo form_submit('btn_login', 'Log In');
echo ' ';
echo form_button('btn_forgot', 'Forgot');
echo form_close();
Controller:
Code:
function widget() {
$redirect_location = "name of url to redirect";
if($this->input->post('btn_login')){
$username = $this->input->post('txt_email');
$password = $this->input->post('txt_password');
if(Modules::run('user/validate_login', $username, $password)) {
redirect(base_url() . $redirect_location);
} else {
redirect(base_url());
}
}
$this->load->view('widget');
}
If I want to have a login on two (2) different pages, I simply call the login module which is
Module::run('login/widget'). For this example, how can I handle the redirects if this will be on two different pages? The solution that I think of is to pass variables. But is it a good practice?