Jump to content

Recommended Posts

You cannot ban them from injecting harmful code, but you can stop the code from running.

 

For example, if the text box is to be for a user's name, chances are they will not need to enter any html tags, so a simple strip_tags will prevent an XSS exploit and if it is going into the database, filtering the data or at least mysql_real_escape_stringing the data will prevent SQL Injection. For a more thorough description see this PHP Security Tutorial.

So can I just use mysql_real_escape_string() on all my text boxes instead of the strip tags?

 

Read the tutorial.

 

But as I said, strip_tags will prevent XSS exploits, if the text box is not suppose to contain HTML / JavaScript. XSS exploits is basically someone writing javascript code that gets run on the page which can inject cookies / redirect users to certain pages etc.  Those 2 functions prevent 2 seperate items.

 

If you are allowing HTML (not to be executed) in a textbox, you will want to look into htmlentities. Since this has been hit so many times, and I have given you the terms to search for, I will not go into greater detail on how to "secure" your script. Look at the tutorial I posted and google "prevent xss php" for more information. You can read and do research as well as I can, and since you are the one who wants to learn this, I will let you do the research.

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.