Reputation: 6635
I am inserting data into a mySQL database, but I am inserting banking details so it is very sensitive, how can I secure it and protect against it getting into the wrong hands?
At the moment the code is still very basic, without any preventative measures in place,
mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("db") or die(mysql_error());
$result = mysql_query("INSERT INTO table (id, name, surname)
VALUES (NULL, '".$_SESSION['name']."', '".$_SESSION['surname']."' )")
or die(mysql_error());
Thanx in advance!
Upvotes: 1
Views: 419
Reputation: 6450
If you're seriously storing banking details please read as much as you possibly can in this area; consider hiring someone with a lot of expertise in the field.
Sensitive data's like landmines, you don't want to touch it unless you really know what you're doing.
Edit - I want to clarify I'm being deadly serious here, not flippant. If I were given a project like this I would raise a big "out of my depth" flag to protect myself and my company. IMO this is one of these projects where failure to provide adequate infrastructure and process could lead to a company-destroying compromise.
I could well be overreacting here, but I'm trying to offer genuine advice that I'd give to a friend or colleague who came to me with the same question.
Upvotes: 7
Reputation: 53830
These are just suggestions that I didn't see anybody else make.
Upvotes: 0
Reputation: 178
You'll need to encrypt the sensitive data before it goes into the database. Mcrypt is a common way of doing so within PHP.
Upvotes: 2
Reputation: 48016
You should look for security in the following places:
Read this thread and it will teach you a lot about building websites
Upvotes: 1
Reputation: 3375
It appears that you are writing a PHP application (which I'll assume will be deployed to the web)
Upvotes: 4
Reputation: 382696
You should really use Prepared Statements to secure yourself.
Your sample code is way too risky !
Upvotes: 3
Reputation: 486
You need to prevent SQL injections. Use mysql_real_escape_string() around all your variables you're inserting. Better yet, use PDO and prepared statements. Even better, use PDO and stored procedures.
Upvotes: 0