My form saves user inputs (inputs+textarea) into a flat file database.
I found lots of examples Googleing on how to create a flat file database, but no one is properly covering some good basics on how to properly secure form from XSS and other malicious attacks.
I know the best way is to have (Ex:) an SQL database… but that’s not the case.
So far I know (this could be wrong! correct me if it is) :
- Preferably use .php files to store data (inside
<?php ...data... ?>) instead of .txt files - If possible drop an .htaccess with a
deny from allinside the database folder - Validate via php your inputs and textarea before submission. (But how to do that exactly??? I mean… what’s the best way?)
- validate properly your fields (php) (How exactly… some practices are only for sql databases, not for ffdb…)
- I’m looking something like
mysql_real_escape_stringbut good enough for ffdb
What are your thoughts?
I appreciate your help
Dunno where did you get it, but by using
you can be definitely sure that it will ALLOW anyone whatever attack they wish,
makes absolutely no sense,
So, it seems the only issue is
and it is solved by using
htmlspecialchars()here is an example of such a script I wrote long time ago in a galaxy far, far away…
Feel free to ask if something looks unclear.
it will produce a so-called pipe-delimited format like this
you can read it using file()+explode()