Jump to content

text box security


asmith

Recommended Posts

leaving an input filed with no limit ,can cause sql injections .

what about a text box  ?   

i want to allow the user to type anything he wants for something like "comments" . so he can use all the symbols ,space , everything .

and i want to record that in mysql field. 

how can i prevent my text box not to allowed sql injections  ?

 

( hmm i can combine the incoming text with some symbols at the its front and its end  , so to make it change from what it is exactly , but is there a better way for doing this ? )

Link to comment
Share on other sites

mysql_real_escape_string - that does it all for you.

 

EXCEPT - I did read an article recently (which I can't locate right now) stating that if you entered the utf8 (either that or a similar character code) for a single quote then it is not escaped by mysql_real_escape_string but is evaluted as a single quote in a string and hence would permit injection.

 

Inject is only really a problem with select queries anyway - inserts and updates would only be affected in rare situations where your construction of the query string allowed the user inputted string to affect which/howmany rows were affected....

Link to comment
Share on other sites

I believe this

EXCEPT - I did read an article recently (which I can't locate right now) stating that if you entered the utf8 (either that or a similar character code) for a single quote then it is not escaped by mysql_real_escape_string but is evaluted as a single quote in a string and hence would permit injection.

is incorrect. The addslashes() function has this problem, not mysql_real_escape_string().

 

Ken

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.