08-31-2007, 04:05 PM
[eluser]jvittetoe[/eluser]
in my current application, once a user logins in they are redirected to their dashboard, via the dashboard.php controller. currently residing at www.myproject.com/dashboard
now from this page there is a link to modify settings. once clicked they are then routed to www.com/dashboard/settings - this function from within the dashboard controller loads a view file...
now from the dspSettings view file there is a form. im using the ci form helper. the form is as follows...
on submission, the form routes to the dashboard/updateUserAccount function:
the current url is www.com/dashboard/updateUserAccount which brings up errors telling me 'Undefined property: password_new' because that field was submitted empty. how can i keep the field optional and still modify a record in the database without running into errors like this.
im still new to the framework and developing in general. how is my structure. could i be doing these easier and faster? thanks.
in my current application, once a user logins in they are redirected to their dashboard, via the dashboard.php controller. currently residing at www.myproject.com/dashboard
now from this page there is a link to modify settings. once clicked they are then routed to www.com/dashboard/settings - this function from within the dashboard controller loads a view file...
Code:
$template['mainContent'] = $this->load->view('dspSettings', $data, true);
$this->load->view('layDash', $template);
now from the dspSettings view file there is a form. im using the ci form helper. the form is as follows...
Code:
<?=form_open('dashboard/updateUserAccount'); ?>
<label for="modify_oldpassword">Old Passsword</label><br />
<input type="password" name="password_old" id="modify_oldpassword" value="" /><br />
<label for="modify_newpassword">New Passsword</label><br />
<input type="password" name="password_new" id="modify_newpassword" value="" /><br />
<label for="modify_confpassword">Confirm New Passsword</label><br />
<input type="password" name="password_conf" id="modify_confpassword" value="" /><br />
<label for="modify_firstname">First Name</label><br />
<input type="text" name="firstname" id="modify_firstname" value="" /><br />
<label for="modify_lastname">Last Name</label><br />
<input type="text" name="lastname" id="modify_lastname" value="" /><br />
<label for="">Delete Account?</label><br >
<input type="checkbox" value="0" id="modify_deleteaccount" /><label for="modify_deleteaccount" class="selectable">Check here to delete your account.</label><br />
<input type="submit" value="Modify Settings" />
</form>
on submission, the form routes to the dashboard/updateUserAccount function:
Code:
function updateUserAccount(){
$data['title'] = "My Finance ~ v1.00 ~ Dashboard";
$data['status'] = "PLEASE LOGIN";
$rules['password_old'] = 'trim|required';
$rules['password_new'] = 'trim';
$rules['password_conf'] = 'trim';
$rules['firstname'] = 'trim';
$rules['lastname'] = 'trim';
$this->validation->set_rules($rules);
$template['mainContent'] = $this->load->view('dspSettings', $data, true);
$this->load->view('layDash', $template);
if($this->validation->run() == FALSE){
$data['status'] = "Invalid Login";
redirect('/dashboard/settings/', 'refresh');
} else {
$password_old = $this->validation->password_old;
$password_new = $this->validation->password_new;
$password_conf = $this->validation->password_conf;
$firstname = $this->validation->firstname;
$lastname = $this->validation->lastname;
//DISREGUARD BELOW THIS LINE
//HAVENT GOT THERE YET
if ($this->userAccountHandling->modifyUserAccount($password_old, $password_new, $password_conf, $firstname, $lastname)) {
$data['title'] = "My Finance - v1.00";
$data['status'] = "USER ACCOUNT FOUND - LOGGING IN";
//USER ALREADY EXISTS
//LOG USER IN
if ($this->userAccountHandling->loginTheUser($emailaddress, $password) == TRUE) {
//successful login
//$this->load->view('layMain');
redirect('/dashboard/', 'refresh');
}
}
}
}
the current url is www.com/dashboard/updateUserAccount which brings up errors telling me 'Undefined property: password_new' because that field was submitted empty. how can i keep the field optional and still modify a record in the database without running into errors like this.
im still new to the framework and developing in general. how is my structure. could i be doing these easier and faster? thanks.