Jump to content

MYSQL INJECTION, how to stop it?


Orionsbelter

Recommended Posts

hi i know the mysql_espace_string()  and the addslashes() but what i need to know is are there any other ways and also can i use these for username string for example if someone logs in to my websites and it addslashes wont it just totally change the username?

 

e.g. username's login would change to username'/s login then my website would think its a invaild username wouldn't it ?

 

and is there a fucntion to remove these slashes?

 

Link to comment
Share on other sites

Well if you used addslashes on the register page the username would be "username'/s login" if you also use addslashes on the login page then it would still be "username'/s login" so it would work.

 

You could then use stripslashes() to remove the ' if you wanted to print it to the screen.

 

But like awpti said, you should keep it alphanumeric if you can.

Link to comment
Share on other sites

DO NOT use addslashes.

 

Always use mysql_real_escape_string() instead while a mySQL connection is in existence.

 

addslashes is open to being fooled.

 

As the guys above said, try to force usernames into being only A-Z 0-9.

 

On list menu forms, give you options corresponding numbers and then check if they are numeric with is_numeric() which returns a 1 if it is.

 

Try to use only numerical values for GET values and check to see if they are numerical (also use strip_tags).

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.