Skip to content

Commit

Permalink
Updated DB connect to use dotenv. Index now loads requirements and bo…
Browse files Browse the repository at this point in the history
…otstrap file and new include method for templates.
  • Loading branch information
justinhartman committed Oct 17, 2018
1 parent 833617d commit a19506d
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 6 deletions.
34 changes: 33 additions & 1 deletion config/connect.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
<?php
$connection = mysqli_connect('localhost', 'root', 'funk19', 'ecomphp');
/**
* Advanced PHP 7 eCommerce Website (https://22digital.agency)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @copyright Copyright (c) 22 Digital (https://22digital.agency)
* @copyright Copyright (c) Justin Hartman (https://justinhartman.blog)
* @author Justin Hartman <justin@hartman.me> (https://justinhartman.blog)
* @link https://github.com/justinhartman/complete-php7-ecom-website GitHub Project
* @since 0.1.0
* @license https://opensource.org/licenses/AGPL-3.0 AGPL-3.0
*/

/**
* Get and Set the environment variables.
*/
$dbHost = getenv("DB_HOST");
$dbUsername = getenv("DB_USERNAME");
$dbPassword = getenv("DB_PASSWORD");
$database = getenv("DB_DATABASE");

$connection = mysqli_connect($dbHost, $dbUsername, $dbPassword, $database);
if (!$connection) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
Expand Down
46 changes: 41 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
<?php
session_start();
require_once 'config/connect.php';
include 'inc/header.php'; ?>
<?php include 'inc/nav.php'; ?>
/**
* Advanced PHP 7 eCommerce Website (https://22digital.agency)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @copyright Copyright (c) 22 Digital (https://22digital.agency)
* @copyright Copyright (c) Justin Hartman (https://justinhartman.blog)
* @author Justin Hartman <justin@hartman.me> (https://justinhartman.blog)
* @link https://github.com/justinhartman/complete-php7-ecom-website GitHub Project
* @since 0.1.0
* @license https://opensource.org/licenses/AGPL-3.0 AGPL-3.0
*/

/**
* Check platform requirements.
*/
require __DIR__ . '/config/requirements.php';

/**
* Load the bootstrap file.
*/
require __DIR__ . '/config/bootstrap.php';

/**
* Load the template files.
*/
include INC . 'header.php';
include INC . 'nav.php';
?>

<!-- SHOP CONTENT -->
<section id="content">
Expand Down Expand Up @@ -70,4 +106,4 @@
</div>
</section>

<?php include 'inc/footer.php' ?>
<?php include INC . 'footer.php'; ?>

0 comments on commit a19506d

Please sign in to comment.