personal-website/docs/common/header.php
2024-04-27 21:09:42 +02:00

58 lines
1.4 KiB
PHP
Executable file

<!DOCTYPE html>
<?php
// Include config file
include_once("config.php");
// Start session
session_start();
// PDO Mysql connection object
$conn = "";
/** Attempt to connect to sql database
*/
function attempt_sql_connect() {
// access global $conn
global $conn;
// Load the global login constants
$sql_hostname = SQL_HOSTNAME;
$sql_database = SQL_DATABASE;
$sql_username = SQL_USERNAME;
$sql_password = SQL_PASSWORD;
try {
//Try connecting to the SQL database
$conn = new PDO("mysql:host=$sql_hostname;dbname=$sql_database",
$sql_username, $sql_password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
$conn = null;
return;
}
}
attempt_sql_connect();
?>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="icon" href="http://www.zdenekborovec-dev.cz/favicon.ico">
<link rel="stylesheet" href="http://assets.zdenekborovec-dev.cz/common/styles.css?1703173954">
<title><?= isset($PageTitle) ? $PageTitle : "Zdenek Home Page"?></title>
</head>
<body>
<main>
<div id="header">
<h1> Zdenek Borovec Home Page </h1>
<ul>
<li><a href="http://www.zdenekborovec-dev.cz">About</a></li>
<li><a href="http://www.zdenekborovec-dev.cz/blog">Blog</a></li>
<li>Gallery</li>
<li><a href="http://www.zdenekborovec-dev.cz/random">Random Tools</a></li>
</ul>
</div>