Welcome Guest, Not a member yet? Register   Sign In
validating non form data
#1

[eluser]Unknown[/eluser]
Hi ... I would like up upload a data file, then open that data file, read off the data, and finally validate that data before uploading it into a database table.

I know how to use the form_validation class to validate form data. But I can't figure out how to use the form_validation class to validate the data I've read from a file!

(I'm hoping I can use the form_validation class for this ... it would be tragic if I'd have to write my own validation routines just for this stupid file data! Sad

thanks!
#2

[eluser]pickupman[/eluser]
The form validation class can only check if file has been uploaded. I do this same very thing as you are trying. I am uploading price sheets in CSV, and if the data matches, it is inserted/updated in DB. Use the validation class to check file has been uploaded. If the file has been uploaded, use fopen() or load the CI file helper, and use read_file(). I run the file through a loop reading each line. I use a regular expression to check the fields in each row. If it passes the regex test, I added it to the DB.
#3

[eluser]Unknown[/eluser]
Thank you, I appreciate it ... I guess regex is it!




Theme © iAndrew 2016 - Forum software by © MyBB