Jump to content

securing user form input to mysql


Yeodan

Recommended Posts

Well that depends you could ofcourse also use strip_tags() if you don't want any html tags in your database

 

are html tags capable of doing anything bad or wrong in my database?

or will they do anything bad to the way my website looks?

if not I don't really mind, but I guess they will? =(

Link to comment
Share on other sites

mysql_real_escape_string() is secure enough to prevent SQL Injection attacks when taking user input and storing it in the database. Should note that this function sends the data to the database to be escaped, so if for example you are looping a lot of queries, or inserting a long list of fields (such as a registration form) then the database is going to take a lot of hits. An alternative in that case is MySQLi Prepared Statements, which will take care of all the SQL Injection prevention for you.

 

 

If you are displaying user input on the page then you should consider removing any HTML tags because if you don't you would be vulnerable to an XSS (aka cross site scripting) attack, basically where a user could insert malicious javascript into the page.

Link to comment
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.