0

Possible Duplicate:
How to prevent SQL injection?

I need to know what is the best way to stop SQL injection in a php website.? Also i have a problem. When i fire any query which contains the data having ' or ", the query does not execeute its funcioning. Whats the reason for this and whatr could be the possible solution? Also i need to know what is MD5 and how can i use it my code for storing data. Also, is it possible to revert back the MD5 text to original text??

How can i use MD5 hash to store password in php. and how to use them later on as from what i have heard , it is not possible to revert back the MD5.

Community
  • 1
  • 1
Ashish Kumar Gupta
  • 279
  • 2
  • 3
  • 9
  • I would suggest a Google. With regards to ' & " problem, you should post a sample code that you are using. – Vishnu Dec 09 '12 at 12:18
  • Short answer: Use PDO or MYSQLI to prevent SQLinjections, MD5 is not reversable. You may use the `md5()` function to generate a MD5 hash from a text. – HamZa Dec 09 '12 at 12:21
  • The best way to avoid SQL injection is by using addslashes function $name = addslashes($_POST['name']); $SQL = "SELECT * FROM table WHERE name='$name'"; About the "or" function, I need a piece example of the code to help You can use md5 by using md5() function $password = md5($password); It is impossible to get the original text back. You cannot revert it back, but you can use something like this: $SQL = "SELECT * FROM usr WHERE name='$name' AND password ='".md5($password)."'"; – goFrendiAsgard Dec 09 '12 at 12:22

0 Answers0