Welcome Guest, Not a member yet? Register   Sign In
Hidden field not been submitted with form validation
#6

(This post was last modified: 12-28-2015, 01:00 AM by wolfgang1983.)

(12-28-2015, 12:50 AM)Diederik Wrote: Ah yes, sorry I didn't spot that error in my first response. You need to tell the validation library which rules needs to be applied for each POST variable. You should always make your validation rules as strict as possible. In your case you expect a value of 1 and nothing else.

Code:
$this->form_validation->set_rules('down_vote', 'Down Vote', 'trim|required|integer');

This way the form is only validated when a integer is posted and not some SQL injection hacker string for example. Not that it matters in your particular codeset because you don't use the posted value itself but it's good practice to make sure all the posted fields contain data of a type that you expect it should be before you can (safely) use that data.

Here is a list with all the build in validation rules:
https://www.codeigniter.com/userguide3/l...-reference

But you can also write your own validation rules to meet your needs.

That is really good to know thanks. I am having a go at making my own forum even though there are some all ready out there just good practice. With bootstrap etc and moderator & user groups etc
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
RE: Hidden field not been submitted with form validation - by wolfgang1983 - 12-28-2015, 12:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB