Welcome Guest, Not a member yet? Register   Sign In
Newbie question - After db update, problem with load - view
#1

[eluser]Unknown[/eluser]
Hello, I'm pretty new to Code Ignitor, but I'm truly loving working with it.

I have a simple controller updating a users status. I'm using the update string, and then trying to load the users page to display their newly updated status. The update string is working fine. The page I'm trying to load is loading, but the variable I'm trying to pass in the $user array seems to be unavailable. On the view page, I'm looking for $user_id. Here's the code:

Code:
$user_id = set_value('user_id');
$user_status = set_value('user_status');

$data = array('status' =>  $user_status);
$where = "id = $user_id";
$sql = $this->db->update_string('Extranet_Users', $data, $where);

$user = array('user_id' => $user_id);

$this->load->view('admin/userdetail', $user); return false;

Thanks for any insight!
#2

[eluser]jedd[/eluser]
What do you get if you insert this into your controller:

Code:
$user['user_id'] = "foo";
$this->load->view('admin/userdetail', $user);


And then in your view, do:

Code:
<?php echo $user_id; ?>
#3

[eluser]Unknown[/eluser]
Thanks Jedd. I figured it out, and it was a pretty silly mistake.

I was using the following to retrieve my form values in the controller:
Code:
$user_id = set_value('user_id');

After reading some more posts here, I realized I should have been using:
Code:
$user_id = $this->input->post('user_id');

Doh!

Once I made this change, everything started working as expected. set_value works in the controller, so I've used it in controllers several times throughout this little app! So, now I'm going to go through and correct that.

Thanks for the reply.




Theme © iAndrew 2016 - Forum software by © MyBB