rework config-file

master
Eirik Th S 2021-04-18 21:02:22 +02:00
parent aa65626bb4
commit fab37f47bb
4 changed files with 24 additions and 7 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
webdata/connection.php
webdata/config.php
temp/

10
webdata/config.php.sample Normal file
View File

@ -0,0 +1,10 @@
<?php
$config["db"]["host"] = "localhost";
$config["db"]["user"] = "user";
$config["db"]["pass"] = "password";
$config["db"]["database"] = "database";
$config["general"]["projectRoot"] = "/groceries";
?>

View File

@ -1,3 +0,0 @@
<?php
$db = new mysqli("localhost","user","password","database");
?>

View File

@ -4,12 +4,22 @@ ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once 'config.php';
$projectRoot = $config["general"]["projectRoot"];
function database(){
require 'connection.php';
global $config;
$db = new mysqli($config["db"]["host"], $config["db"]["user"], $config["db"]["pass"], $config["db"]["database"]);
if($db->connect_error){
die("Connection failed: " . $blogdb->connect_error);
die("Connection failed: " . $db->connect_error);
}
return $db;
}
function checkLogin(){
}