Welcome Guest, Not a member yet? Register   Sign In
form validation question
#3

[eluser]SitesByJoe[/eluser]
Your structure looks pretty good.

You're correct with the way things work, of everything passes validation, the post data should be safe to add to the database.

Things to improve it would be to move your rule declarations into a form_validation config file (see userguide) and moving some of your database calls inside your if() conditional since you only need them when calling your form, not when processing your post data.

Another thing I like to do is to set a success message and then redirect after running the database sequence. Something like:

Code:
// set a temporary success message
$this->session->set_flashdata('message', 'Post added successfully');

// redirect to a new screen based on our new id
redirect('controller/method/' . $this->db->insert_id());

I then run a conditional check on my view template that pops up if the flashdata message has been set.


Messages In This Thread
form validation question - by El Forum - 06-09-2011, 01:40 AM
form validation question - by El Forum - 06-09-2011, 09:09 AM
form validation question - by El Forum - 06-09-2011, 09:26 PM
form validation question - by El Forum - 06-09-2011, 10:48 PM
form validation question - by El Forum - 06-10-2011, 01:47 AM
form validation question - by El Forum - 06-10-2011, 08:19 AM
form validation question - by El Forum - 06-13-2011, 02:06 AM
form validation question - by El Forum - 06-13-2011, 07:35 AM
form validation question - by El Forum - 06-13-2011, 11:22 AM
form validation question - by El Forum - 06-14-2011, 01:14 AM
form validation question - by El Forum - 06-14-2011, 01:33 AM
form validation question - by El Forum - 06-15-2011, 09:11 AM
form validation question - by El Forum - 06-15-2011, 10:23 AM
form validation question - by El Forum - 06-16-2011, 03:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB