PDA

View Full Version : Problem with Security when inserting HTML/javascript code into MYSQL table fields


student
07-20-2008, 06:53 AM
Hello,
We run an affiliate program and affiliates send visitors to our site.
We would like to allow our affiliates to customize their landing pages by allowing them to add any HTML / javascript / text to it.

For example: affiliates may insert their google adsense code etc.

So, we need to insert this data in to the database table:
id
name
email
code

This 'code' will be any HTML / javascript / text.

Later we read from the table and insert that HTML / javascript / text into the landing page.

I doubt if any user may input any malicious script or code.

How to ensure the safety of the database while inserting that code.

Please suggest.
Thank you.

_Aerospace_Eng_
07-21-2008, 05:33 AM
Not sure what you are asking. If you are worried about quotes and what not in the code then run it through mysql_real_escape_string on the data before it goes into the database.