How do you store database credentials in typical cms build on php in PHP Server Side Scripting Language?

Asked By: Asmita Mehrotra

Available Answers: 1

Answer #1#
Meerut, India

You can use a singleton class, as you mentioned, or something simpler.

In all my config.inc.php files I have a standard associative array

$config['Main_Database'] = '';"$config['db_user'] = '';"$config['db_pass'] = '';"$config['db_host'] = '';

The concept is the same and you're on the right track. Make it something that, as a human, makes sense to you. If someone has access to your server your screwed anyway so it's not a big deal in terms of what is more secure.

As for the install file, I've seen many apps open the config file, adjust a few specific parts via the code and then actually re-write the file back to the server (rather than "store a setting"). It achieves the same result but done through a wizard as opposed to manually.

Comment Below

Report

Would you like to join Ask Sawal!

Why?

  1. Ask Sawal is a fast growing question and answer discussion forum.

  2. 25 lakh+ questions were answered by our Ask Sawal Members.

  3. Each day 1000s of questions asked & 1000s of questions answered.

  4. Ask any question and get answer from 5 Lakh+ Ask Sawal Members.

  5. Constant moderation and reporting option makes questions and answers spam free.

  6. And also, we have free blogging platform. Write an article on any topic.

  7. We have 10000+ visitors each day. So a beneficial platform for link building.

  8. We are allowing link sharing. Create backlinks to your blog site or any site.

  9. Gain extra passive income by sharing your affiliate links in articles and answers.