Shalazar
02-28-2000, 09:53 PM
Wow, it's amazing anyone can find anything in this PHP documentation :)
I think I've solved my own form problem, and would like to pass along the knowledge to everyone else, should it be correct.
I have several free-form TEXTAREA text boxes that users can fill in before submitting to the datatbase.[nbsp][nbsp]I've been trying to find the best way to protect that input from being fed malicious text, be it HTML formatting, SSIs, or even PHP commands.
At first, I was going to rely on regular expressions, but felt that would be way too limiting and could not provide an option to tell the user exactly what was wrong with their input.
Then I was referred to addslashes(), which managed to only escape single and double quotes so MySQL wouldn't get hung up on itself.[nbsp][nbsp]Then I found strip_tags(), which is a delightful little function which wipes out anything embedded in an HTML or PHP tag, leaving plain text untouched.
So I think my arsenal is complete for the remainder of this form.[nbsp][nbsp]First executing the addslashes() command to escape the quotes (remember to use stripslashes() if you want to echo it back!) combined with the strip_tags() function to eliminate any funny business.
From what I've read, its a brute force method, and not very intelligent at that, but I'm going to try it out, unless anyone else has any contradictory advice.
I think I've solved my own form problem, and would like to pass along the knowledge to everyone else, should it be correct.
I have several free-form TEXTAREA text boxes that users can fill in before submitting to the datatbase.[nbsp][nbsp]I've been trying to find the best way to protect that input from being fed malicious text, be it HTML formatting, SSIs, or even PHP commands.
At first, I was going to rely on regular expressions, but felt that would be way too limiting and could not provide an option to tell the user exactly what was wrong with their input.
Then I was referred to addslashes(), which managed to only escape single and double quotes so MySQL wouldn't get hung up on itself.[nbsp][nbsp]Then I found strip_tags(), which is a delightful little function which wipes out anything embedded in an HTML or PHP tag, leaving plain text untouched.
So I think my arsenal is complete for the remainder of this form.[nbsp][nbsp]First executing the addslashes() command to escape the quotes (remember to use stripslashes() if you want to echo it back!) combined with the strip_tags() function to eliminate any funny business.
From what I've read, its a brute force method, and not very intelligent at that, but I'm going to try it out, unless anyone else has any contradictory advice.