Jump to content

MySQL username/password usage


beyuch

Recommended Posts

Hello everyone...

 

Ive been using MySQL and PHP for some time now but my code has never been right.

 

In my code I always store the username and password.. the reason for this is because I have always required a quick and dirty solution and it did the job.

 

Anyway... the reason I am posting this is because I want some advise on the best way to store a username/password that can be used by all scripts.

 

Typically I see on sites and in CMSs such as Joomla, that the username/password is stored in a configuration/config file and is 'included' - in plain text.

 

Is this the way to do it?

 

Is there a better solution?

 

 

Link to comment
Share on other sites

Just store it out of the document root and call it a day....

 

The way I'm doing this right now is by having an init.php and a config.php. All of my files include the init.php file, which simply references the config file. As long as I have the path in the init.php file right, all the other files will have access to the variables without having to implicitly include it.

 

So, then you just move the config.php file (the one with db credentials) to a place not publicly accessible, or completely out of the public_html directory. Then change the reference in the init.php file. It's very easy and makes the code easy to move and update.

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.