-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
79 lines (70 loc) · 2.07 KB
/
functions.php
File metadata and controls
79 lines (70 loc) · 2.07 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* pdo_connect_mysql
*
* return une instance de la classe PDO
*
* @return PDO|never
*/
function pdo_connect_mysql() {
$DATABASE_HOST = 'localhost';
$DATABASE_USER = 'root';
$DATABASE_PASS = '';
$DATABASE_NAME = 'shoppingcart';
try {
$pdo = new PDO('mysql:host=' . $DATABASE_HOST . ';dbname=' . $DATABASE_NAME . ';charset=utf8;port=3306', $DATABASE_USER, $DATABASE_PASS);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $pdo;
} catch (PDOException $exception) {
// S'il y a une erreur avec la connexion, arrête le script et affiche l'erreur.
exit('Failed to connect to database! ' . $exception->getMessage());
}
}
// HEADER
function template_header($title) {
echo <<<EOT
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>$title</title>
<link href="style4.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
<div class="content-wrapper">
<h1>Gaming </h1>
<nav>
<a href="index.php">Home</a>
</nav>
<div class="link_cart">
<a href="index.php?page=new_product">new product</a>
</div>
<div class="link_cart">
<a href="index.php?page=cart">cart</a>
</div>
</div>
</header>
<main>
EOT;
}
// FOOTER
function template_footer() {
echo <<<EOT
</main>
<footer>
<div class="content-wrapper">
<ul>
<P > <span style="font-size:20px;font-weight:bold">contact us on : </span> </P>
<li>FACEBOOK : Gaming_facebook</li>
<li>INSTAGRAM : Gaming_instagram</li>
<li>TWITTER : Gaming_twitter</li>
</ul>
</div>
</footer>
<script src="script.js"></script>
</body>
</html>
EOT;
}
?>