Skip to content

Commit a19506d

Browse files
committed
Updated DB connect to use dotenv. Index now loads requirements and bootstrap file and new include method for templates.
1 parent 833617d commit a19506d

File tree

2 files changed

+74
-6
lines changed

2 files changed

+74
-6
lines changed

config/connect.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
<?php
2-
$connection = mysqli_connect('localhost', 'root', 'funk19', 'ecomphp');
2+
/**
3+
* Advanced PHP 7 eCommerce Website (https://22digital.agency)
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as
7+
* published by the Free Software Foundation, either version 3 of the
8+
* License, or (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @copyright Copyright (c) 22 Digital (https://22digital.agency)
19+
* @copyright Copyright (c) Justin Hartman (https://justinhartman.blog)
20+
* @author Justin Hartman <justin@hartman.me> (https://justinhartman.blog)
21+
* @link https://github.com/justinhartman/complete-php7-ecom-website GitHub Project
22+
* @since 0.1.0
23+
* @license https://opensource.org/licenses/AGPL-3.0 AGPL-3.0
24+
*/
25+
26+
/**
27+
* Get and Set the environment variables.
28+
*/
29+
$dbHost = getenv("DB_HOST");
30+
$dbUsername = getenv("DB_USERNAME");
31+
$dbPassword = getenv("DB_PASSWORD");
32+
$database = getenv("DB_DATABASE");
33+
34+
$connection = mysqli_connect($dbHost, $dbUsername, $dbPassword, $database);
335
if (!$connection) {
436
echo "Error: Unable to connect to MySQL." . PHP_EOL;
537
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;

index.php

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,44 @@
11
<?php
2-
session_start();
3-
require_once 'config/connect.php';
4-
include 'inc/header.php'; ?>
5-
<?php include 'inc/nav.php'; ?>
2+
/**
3+
* Advanced PHP 7 eCommerce Website (https://22digital.agency)
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as
7+
* published by the Free Software Foundation, either version 3 of the
8+
* License, or (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @copyright Copyright (c) 22 Digital (https://22digital.agency)
19+
* @copyright Copyright (c) Justin Hartman (https://justinhartman.blog)
20+
* @author Justin Hartman <justin@hartman.me> (https://justinhartman.blog)
21+
* @link https://github.com/justinhartman/complete-php7-ecom-website GitHub Project
22+
* @since 0.1.0
23+
* @license https://opensource.org/licenses/AGPL-3.0 AGPL-3.0
24+
*/
25+
26+
/**
27+
* Check platform requirements.
28+
*/
29+
require __DIR__ . '/config/requirements.php';
30+
31+
/**
32+
* Load the bootstrap file.
33+
*/
34+
require __DIR__ . '/config/bootstrap.php';
35+
36+
/**
37+
* Load the template files.
38+
*/
39+
include INC . 'header.php';
40+
include INC . 'nav.php';
41+
?>
642

743
<!-- SHOP CONTENT -->
844
<section id="content">
@@ -70,4 +106,4 @@
70106
</div>
71107
</section>
72108

73-
<?php include 'inc/footer.php' ?>
109+
<?php include INC . 'footer.php'; ?>

0 commit comments

Comments
 (0)