Foppe Hemminga 6 лет назад
Родитель
Сommit
3b64af5188
2 измененных файлов с 18 добавлено и 1 удалено
  1. 2 1
      composer.json
  2. 16 0
      index.php

+ 2 - 1
composer.json

@@ -1,5 +1,6 @@
 {
   "require": {
-    "vlucas/phpdotenv": "3.3.x-dev"
+    "vlucas/phpdotenv": "3.3.x-dev",
+    "ext-pdo": "*"
   }
 }

+ 16 - 0
index.php

@@ -13,6 +13,22 @@
 <body>
 <div class="container">
     <h1>Racing Australia</h1>
+    <?php
+    require_once 'dbconfig.php';
+	$dsn = "pgsql:host=$host;port=5432;dbname=$db;user=$username;password=$password";
+	try{
+		// create a PostgreSQL database connection
+		$conn = new PDO($dsn);
+
+		// display a message if connected to the PostgreSQL successfully
+		if($conn){
+			echo "Connected to the <strong>$db</strong> database successfully!";
+		}
+	}catch (PDOException $e){
+		// report error message
+		echo $e->getMessage();
+	}
+    ?>
 </div>
 <!-- Optional JavaScript -->
 <!-- jQuery first, then Popper.js, then Bootstrap JS -->