-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.php
36 lines (33 loc) · 1.03 KB
/
db.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
//////////////////////////
//Start database connect//
//////////////////////////
$host = "localhost";
$dbname = "task_board";
$username = "root";
$password = "";
try {
$db = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8", $username, $password);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
die("Database connection error: " . $e->getMessage());
}
////////////////////////
//End database connect//
////////////////////////
/////////////////
//Start add log//
/////////////////
function addLog($message, $status) {
global $db;
date_default_timezone_set("Europe/Istanbul");
$query = $db->prepare("INSERT INTO logs (timestamp, message) VALUES (:timestamp, :message)");
$query->bindParam(":timestamp", date("[d.m.Y H:i:s]", time()));
$new_message = $_SESSION["username"].",".$status.",".$message;
$query->bindParam(":message", $new_message);
$query->execute();
}
///////////////
//End add log//
///////////////
?>