![]() |
I get zero value when i save the data - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: I get zero value when i save the data (/showthread.php?tid=48505) |
I get zero value when i save the data - El Forum - 01-19-2012 [eluser]nOsCiRe[/eluser] Anyone can help why i got zero when i save the data from view <?php if(!defined('BASEPATH')) exit('No direct script access allowed'); Class Home extends CI_Controller { function _construct() { parent:: _construct(); } function index() { if($this->session->userdata('logged_in')) { $session_data = $this->session->userdata('logged_in'); $data['username']= $session_data['username']; $this->load->view('home_page',$data); } else { redirect('','refresh'); } } function userprofile($username) { $session_data = $this->session->userdata('logged_in'); $username = $session_data['username']; $this->load->model('user'); $data['result'] = $this->user->userdetails($username); $this->load->view('userprofile_page',$data); } function updatedetails() { $session_data = $this->session->userdata('logged_in'); $username= $session_data['username']; $data = array( 'first_name' =>$this->input->post('firstname'), 'last_name' =>$this->input->post('lastname')); echo var_dump($this->input->post($data)); $this->db->where('username', $username); $this->db->update('ad_users', $data); redirect('home/userprofile/'.$username,'refresh'); } function logout() { $this->session->unset_userdata('logged_in'); redirect('home','refresh'); } } ?> Views <?Php echo form_input('first_name', $firstname);?> <?Php echo form_open(base_url() . 'home/updatedetails');?> I get zero value when i save the data - El Forum - 01-19-2012 [eluser]Jason Stanley[/eluser] Firstly use code tags... come on. Secondly are you referring to this line? Code: echo var_dump($this->input->post($data)); 1) You do not need an echo before a var_dump statement. 2) This doesn't make sense. '$this->input->post($data)' Code: $data = array( 'first_name' =>$this->input->post('firstname'), I get zero value when i save the data - El Forum - 01-19-2012 [eluser]nOsCiRe[/eluser] Thanks for the reply jason I'm referring to this line why i get zero value $data = array( 'first_name' =>$this->input->post('firstname'), 'last_name' =>$this->input->post('lastname')); I get zero value when i save the data - El Forum - 01-19-2012 [eluser]vbsaltydog[/eluser] I dont see a lastname field in your form fields. Hint: http://ellislab.com/codeigniter/user-guide/libraries/input.html I get zero value when i save the data - El Forum - 01-20-2012 [eluser]machouinard[/eluser] As Jason pointed out, some of your code just doesn't make any sense. However... If you're getting 0's in the database, are your first_name and last_name fields the proper type? Varchar as opposed to int, for example? |