Welcome Guest, Not a member yet? Register   Sign In
how do you handle form submissions
#1

[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...
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 />
        &lt;input  type="password" name="password_old" id="modify_oldpassword" value="" /&gt;<br />
        <label for="modify_newpassword">New Passsword</label><br />
        &lt;input  type="password" name="password_new" id="modify_newpassword" value="" /&gt;<br />
        <label for="modify_confpassword">Confirm New Passsword</label><br />
        &lt;input  type="password" name="password_conf" id="modify_confpassword" value="" /&gt;<br />
        <label for="modify_firstname">First Name</label><br />
        &lt;input  type="text" name="firstname" id="modify_firstname" value="" /&gt;<br />
        <label for="modify_lastname">Last Name</label><br />
        &lt;input  type="text" name="lastname" id="modify_lastname" value="" /&gt;<br />
        <label for="">Delete Account?</label><br >
        &lt;input type="checkbox" value="0" id="modify_deleteaccount" /&gt;<label for="modify_deleteaccount" class="selectable">Check here to delete your account.</label><br />    
        &lt;input type="submit" value="Modify Settings" /&gt;
    &lt;/form&gt;

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.


Messages In This Thread
how do you handle form submissions - by El Forum - 08-31-2007, 04:05 PM
how do you handle form submissions - by El Forum - 09-01-2007, 12:11 AM
how do you handle form submissions - by El Forum - 09-02-2007, 10:17 PM
how do you handle form submissions - by El Forum - 09-03-2007, 02:07 PM
how do you handle form submissions - by El Forum - 09-03-2007, 04:47 PM
how do you handle form submissions - by El Forum - 09-04-2007, 06:27 AM
how do you handle form submissions - by El Forum - 09-04-2007, 07:22 AM
how do you handle form submissions - by El Forum - 09-04-2007, 04:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB