Jump to content

Recommended Posts

Hi guys and gals,

 

I am currently working on a database class in OOP PHP5. Its a class which can connect to a database, dynamically build, generate and execute queries and return results.

 

I just have a quick question. I am quite aware of all the ways people can attack databases, web servers etc through badly coded PHP and have tried to make my class a secure as possible. All data being passed to the database is thoroughly validated with my extensive validation class then I use stripslashes() to remove the abomination that is magic_quotes and then run it through mysqli_real_escape_string() this along with my extensive validation protects against SQL injection attacks. However I am now looking into protection against XSS Attacks. I am well in the habit of using htmlentities() function on all text to be output to the browser and this does stop most XSS attacks. However my question is should I use htmlentities() to encode data before it is sent to the database or just encode it before I output it? Will encoding it before stop mysqli_real_escape_string form working properly? It is easier to encode it before insertion to the DB because you dont have to encode all your output on everypage that displays data from the database. What do you all recommend?

 

Sorry for the long post and thanks for your time

 

Kind Regards

Rob

Link to comment
https://forums.phpfreaks.com/topic/69002-security-question/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.