-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.php
48 lines (39 loc) · 1.19 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
<?php
//Connecting to DataBase using Php Data Object.
/*
try {
$dbh = new PDO('mysql:host=localhost;dbname=myblog', 'omar', 'omar123456');
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
//connecting normaly.
$conn= mysqli_connect('localhost','omar','omar123456','myblog');
//write query to get all users.
$sql='select * from users';
//get the results.
$result=mysqli_query($conn, $sql);
//fetch the data rows as an array
$users=mysqli_fetch_all($result, MYSQLI_ASSOC);
//free the result from the memory.
mysqli_free_result($result);
//closing the connection.
mysqli_close($conn);
//print_r($users);
*/
session_start();
//C:\Users\omara\www\collage\MyBlog
define('ROOT_PATH', realpath(dirname(__FILE__)));
//MyBlog/
const BASE_URL = 'http://myblog';
try {
//connecting using PDO
$conn = new PDO('mysql:host=myblog;dbname=myblog;charset=utf8', 'omar', 'omar123456');
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
if (isset($_SESSION['timeout']) && time() > $_SESSION['timeout']) {
header('location: ' . BASE_URL . '/registration/logout.php');
}
?>