-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.php
54 lines (50 loc) · 1.53 KB
/
config.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Created by PhpStorm.
* User: Rzkan
* Date: 05/11/2018
* Time: 0:12
*/
class config{
function getConnection(){
$host = "localhost";
$user = "root";
$pass = "*,[FY&";
$db = "pweb";
try {
$conn = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $conn;
} catch (PDOException $e) {
echo " Error nih : " . $e->getMessage();
}
}
function view($content, $data = NULL){
if($content == 'redirect'){
include('view/redirect.view.php');
}else{
include('view/layout/header.php');
include('view/layout/nav.php');
if ($content == 'index') {
include('view/index.view.php');
} elseif ($content == 'home') {
include('view/home.view.php');
} elseif ($content == 'login') {
include('view/login.view.php');
} elseif ($content == 'register') {
include('view/register.view.php');
} elseif ($content == 'edit') {
foreach ($data as $key) {
$id = $key->id;
$title = $key->name;
$slug = $key->slug;
$url = $key->url;
}
include('view/edit.view.php');
} else {
echo "404";
}
include('view/layout/footer.php');
}
}
}