Are passwords safe in functions.php?
-
I have succeeded in writing a bit of php that pulls data from another (NOT WORDPRESS) MySQL database, and incorporates that data into my WordPress pages. All good.
But in order to do that I had to code the db name, admin username & admin password into my functions.php file
// Create connection
$servername = “localhost”;
$username = “myusername”;
$password = “mypassword”;
$dbname = “myusername”;
$conn = new mysqli($servername, $username, $password, $dbname);
etc…It all works, but this has me nervous that if anyone could view my functions.php file, then they would have my database admin username & password.
I’m a relative newbie at wordpress, php & mysql. How can I hard code a db admin username & password into a php file, yet protect this from prying eyes?
I’ve done a bit of research on the internet, including reading this – https://www.artofblog.com/wordpress-security ; but I don’t feel that I’ve got an answer.
Thanks in advance
- The topic ‘Are passwords safe in functions.php?’ is closed to new replies.