I’m using WordPress as CMS and have a checkout page where info is inserted into the db using $wpdb->insert. I have 2 questions:
- Is ‘sql injection’ already a part of that function or do I need to add my own code?
- Are there wordpress form input validation functions that I can use on my custom form?
When inserting input to the database you should use
prepare
method of WPDB class which supports both asprintf()
– like andvsprintf()
-like syntax. read more at the codexYes there are many and they are covered in Data Validation codex entry like toscho pointed out.
The Codex has a really good page about this topic: Data Validation. There isnât much to add. 🙂