2
0

add: read, write data to database + some explainations

This commit is contained in:
Schuledaniel
2025-12-10 15:04:05 +01:00
parent 385226a4a3
commit 4413283006
3 changed files with 79 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
<?php
// db_connection_data.php
$db_engine ="mysql";
$db_name = "E2FI1_2025";
$db_host = "localhost";
$db_user = "phpmyadmin";
$db_password = "server";

View File

@@ -0,0 +1,20 @@
<?php
// db_connection_function.php
function db_connect(){
require_once("db_connection_data.php");
// db_server = "mysql:dbname=testdb;host:localhost";
$db_server = "$db_engine:dbname=$db_name;host=$db_host";
try {
$dbh = new PDO ($db_server, $db_user, $db_password);
echo "<p>DB Connection succesfull established!</p>";
return $dbh;
} catch (PDOException $e){
//echo "Could not connect to DB!<br> ";
die("More:".$e->getMessage());
}
}
// Test:
// db_connect();