How can PHP define variables be used to enhance security in a login system?

When implementing a login system in PHP, it is crucial to securely handle user input to prevent vulnerabilities such as SQL injection and cross-site scripting attacks. One way to enhance security is by using PHP define variables to store sensitive information such as database credentials or secret keys. By defining these variables in a separate configuration file and including it in the main script, you can prevent accidental exposure of sensitive data in your codebase.

// config.php
<?php
define('DB_HOST', 'localhost');
define('DB_USER', 'username');
define('DB_PASS', 'password');
define('DB_NAME', 'database_name');
define('SECRET_KEY', 'your_secret_key');
?>

// login.php
<?php
require_once('config.php');

// Use the defined variables in your code
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);

// Other login system logic here
?>