[eluser]Solarpitch[/eluser]
Hey Guys,
I have the following index function that will load the login form when the application is loaded. Is it good practice to submit to the same function when the form is submitted?
Because at the min I need a way to only execute the model call if the form is being submitted or should I create a seperate function exec_login or something?
The login model just returns a row count to check to see if the credentials exist.
Code:
function index(){
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->load->model('login_model');
//This will only execute if the form has been submitted...
$username = $this->input->post('username');
$password = $this->input->post('password');
$data['result'] = $this->login_model->auth($username, $password);
$data['form'] = "login_form/form";
$this->load->view('template/login', $data);
}
login_form/form...
Code:
<?php echo validation_errors(); ?>
<?php echo form_open('index'); ?>
<table width='420' border='0' cellspacing='2' cellpadding='0' style='font-family:Arial; font-size:12px; font-weight:bold; color:#5A7B00; '>
<tr>
<td>Account Username:</td>
<td> </td>
</tr>
<tr>
<td><input type='text' name='username' style='width:450px; font-size:23px; color:#999999; ' value="<?php echo set_value('username'); ?>"></td>
<td> </td>
</tr>
<tr>
<td>Password:</td>
<td> </td>
</tr>
<tr>
<td><input type='password' name='password' style='width:450px; font-size:23px; color:#999999; '></td>
<td> </td>
</tr>
<tr>
<td>
<input type='hidden' name='process' value='' />
<input type='hidden' name='ip' value=''>
<input type='image' src='designs/login_bt.jpg' alt='login ' name='process' value='execute'></td>
<td> </td>
</tr>
</table>
</form>