Codeigniter page redirection issue?

You can check if the insert was successful with.

Up vote 0 down vote favorite share g+ share fb share tw.

I am new to codeigniter frame work and I am trying to design a member registration form using that framework. I have used the following code to insert the member. Load->database(); $val = array( 'name' => $this->input->post('name'), 'gender' => $this->input->post('gender'), 'age' => $this->input->post('age'), 'address' => $this->input->post('address'), 'phoneno' => $this->input->post('phone'), ); $insert=$this->db->insert('tbl_member',$val); } }?

> If the member details inserted into the database successfully I have to redirect it to the view member details page with success message. In that page I have to display the member details fetched from the database. I don't know how to redirect and check whether the insert is true.

How can I do that? Codeigniter codeigniter-2 link|improve this question asked Mar 6 at 5:17designersvsoft34310 43% accept rate.

This is really bad form calling $this->input->post('#') inside your model. Please validate in CONTROLLER, then pass sanitized values to your model. A good method is a clean array() of values to insert.

– Jakub Mar 6 at 14:00.

You can check if the insert was successful with: $this->db->affected_rows() to return the number of records inserted. You can then redirect the user to the appropriate page using the URL helper's redirect function: redirect('path/to/redirect/to').

And your insert_success method would be: function insert_success($userId) { $data = $this->db->query('query-to-fetch-details-with-user-id'); return $data->result_array(); }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions