Welcome Guest, Not a member yet? Register   Sign In
How to screen $_POST data before inserting into database?
#1

[eluser]Tony W[/eluser]
I am very new to CI and just started coding. I have read the user guide but still don't know how to do screen the POST data before saving to database?

I only know this for mysql insertion:
$this->db->insert('db_table', $_POST);

How do you screen the data such as:

confirm if the passwords (1st entry and confirm) are identical?

add captcha.

etc...

Thanks!
#2

[eluser]Taff[/eluser]
Hey Tony,
check out the validation class.

http://ellislab.com/codeigniter/user-gui...ation.html

That should be what you need. Scroll down to Prepping data where you will see
Quote:$rules['username'] = "trim|required|min_length[5]|max_length[12]|xss_clean";
$rules['password'] = "trim|required|matches[passconf]|md5";
$rules['passconf'] = "trim|required";
$rules['email'] = "trim|required|valid_email";

which will give you a basic idea of how it works.

Taff




Theme © iAndrew 2016 - Forum software by © MyBB