Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP MySQL
Dear Friends,
 
I am developing a website in PHP using MySQL Database.
 
When I connect to MySQL database, I need to give the username and password.
I want to know that where should I store this password and username, so that when I need to give the username and password, I retrieve it from that place.
 
I want to secure my username and password.
Posted 31-Mar-11 2:14am
Edited 31-Mar-11 5:28am
v3
Comments
Dalek Dave at 31-Mar-11 10:29am
   
Edited for Grammar and Readability.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

You can write a php file with just MySQL connection detail and store it as connection.php. And then you can include it in every php file that requires to connect to the DB using the
 
<?php require_once("connection.php")
 
You can make use of
<?php include("connection.php")
too but this might error out some time with Too many connection error.
 
As the scripts are not readable from the browser in txt mode you don't have to worry about the security issues too.
 
BR//
Harsha
  Permalink  
v2
Comments
Dalek Dave at 31-Mar-11 10:29am
   
Nice.
rashidfarooq at 31-Mar-11 13:08pm
   
Although I am using this method yet. But If some one access my connection.php file, then he will get my username and password. Plz tell me some solution keeping in view this point.
harsha narayana at 1-Apr-11 1:48am
   
Well, first of all its really tough to get access to your script files in the server as apache has a really good security measure towards this.
 
There are tools like Turck MMCache, CodeLock, which will help you encode your script files before deploying them on the server. Which can come in handy for the purpose that you are looking for.
http://turck-mmcache.sourceforge.net/index_old.html#encoder
But the MMCache tool is for linux environment. So i would suggest you encrypt your file in Linux and then deploy them on any platform you choose to.
harsha narayana at 1-Apr-11 1:50am
   
http://roshanbh.com.np/2008/01/encryption-and-decryption-technique-in-php.html
 
Try this link. It might help you too
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

create a table in the database
store your user Name and password and if you want security
then you need to encrypt your password before storing it into the Database
and at the time of retrieving that password you need to decrypt that.
  Permalink  
Comments
rashidfarooq at 31-Mar-11 13:10pm
   
Brother I am talking about the DB Username and Password. Until I do no apply username and password to the database, How can I get access to database.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This discussion should give you a direction: Similar topic discussed[^]
 
You need to encrypt the username/password and store it in database or some config/text file accessible.
  Permalink  
Comments
rashidfarooq at 31-Mar-11 13:12pm
   
I am not worried about the usernames and passwords of the users of my site. I am only worried about the DB Username and Password. Plz tell me the solution keeping in view this point.
Sandeep Mewara at 31-Mar-11 13:16pm
   
Same about that. For example, in ASP.NET, we do that in Web.Config file encrypted, if needed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,455
1 OriginalGriff 8,295
2 Peter Leow 4,839
3 Kornfeld Eliyahu Peter 3,210
4 Maciej Los 2,301


Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 31 Mar 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100