diff --git a/main/login.php b/main/login.php index ac05bfb..094f781 100644 --- a/main/login.php +++ b/main/login.php @@ -9,13 +9,18 @@ header('Content-Security-Policy: default-src \'self\'; style-src \'self\' \'unsa header('Strict-Transport-Security: max-age=31536000; includeSubDomains'); session_start(); -$config = require 'config.php'; -$db = new PDO( - "mysql:host={$config['db']['host']};dbname={$config['db']['name']}", - $config['db']['user'], - $config['db']['pass'] -); -$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +try { + $config = require 'config.php'; + $db = new PDO( + "mysql:host={$config['db']['host']};dbname={$config['db']['name']}", + $config['db']['user'], + $config['db']['pass'] + ); + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} catch (PDOException $e) { + error_log("Database connection error: " . $e->getMessage()); + die("Database connection error"); +} $error = ''; $success = ''; @@ -51,6 +56,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $error = 'User not found'; } } catch (PDOException $e) { + error_log("Login error: " . $e->getMessage()); $error = 'Server error'; } }