The question refers to a simple Form using POST method to send data to the server.I am interested in some cases:
1] Data come from a Form Textbox
2] Data come from a Form Listbox
3] Data are used to enter new data in the database
4] Data are used in a query after WHERE to filter out results
Question 1: Is a query safe vs SQL Injections in all combination of the above cases? If not what can I do to make sure I did my best in keeping my code as secure as possible?
What makes me sceptical is that I included the $ComparisonB variable in the mysqli query, using prepared statements though.
Question 2: Assuming we sanitize $ComparisonB vs XSS using the following method:
function xssanitize($data,$encoding='UTF-8')
{
return htmlspecialchars($data,ENT_QUOTES | ENT_HTML401,$encoding);
}
Is it sufficient or should I do something more?
I KNOW that "Security is a state of mind", but I would like to learn to do things as proper as possible.