summaryrefslogtreecommitdiff
path: root/Lab04/insert.php
diff options
context:
space:
mode:
Diffstat (limited to 'Lab04/insert.php')
-rw-r--r--Lab04/insert.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/Lab04/insert.php b/Lab04/insert.php
index 717842e..2172473 100644
--- a/Lab04/insert.php
+++ b/Lab04/insert.php
@@ -8,11 +8,18 @@
<body>
<center>
<?php
- $servername = "db";
- $username = "example";
- $password = "example";
- $dbname = "regformdata";
- $tablename = "regtable";
+ // Load environment variables from .env file
+ require __DIR__ . '/vendor/autoload.php';
+
+ use Dotenv\Dotenv;
+ $dotenv = Dotenv::createImmutable(__DIR__);
+ $dotenv->load();
+
+ $servername = getenv('DB_SERVER');
+ $username = getenv('DB_USERNAME');
+ $password = getenv('DB_PASSWORD');
+ $dbname = getenv('DB_NAME');
+ $tablename = getenv('DB_TABLE');
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
@@ -51,4 +58,4 @@
</center>
</body>
-</html> \ No newline at end of file
+</html>