What potential security concerns arise from using user/password@site.de in PHP scripts?
Using user/password@site.de in PHP scripts can expose sensitive login credentials in plain text, making them vulnerable to unauthorized access if the script is compromised. To address this security concern, it is recommended to store the credentials in a separate configuration file outside of the web root directory and include it in the PHP script securely.
<?php
// config.php
$db_host = 'site.de';
$db_user = 'user';
$db_password = 'password';
$db_name = 'database';
// script.php
include_once('config.php');
// Connect to the database using the stored credentials
$connection = new mysqli($db_host, $db_user, $db_password, $db_name);
if ($connection->connect_error) {
die("Connection failed: " . $connection->connect_error);
}