-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
145 lines (133 loc) · 4.72 KB
/
index.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
include('config.php');
session_start();
if(isset($_POST['password'])) {
$password = filter_var($_POST['password'], FILTER_SANITIZE_STRING);
/*** connect to database ***/
try {
$db = new PDO('mysql:host=localhost;dbname='.DBNAME.';charset=utf8', DBUSERNAME , DBPASSWORD);
/*** set the error mode to excptions ***/
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/*** prepare the select statement ***/
$query = $db->prepare("SELECT * FROM users WHERE user_id = 3 OR user_id = 4");
$query->execute();
$data = $query->fetchAll();
foreach($data as $user) {
if(password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['user_id'];
if($user['user_id'] == "3") {
$_SESSION['admin'] = $user['user_id'];
}
$message = 'You are now logged in';
} else {
$message = 'Login Failed';
}
}
} catch(Exception $e) {
/*** if we are here, something has gone wrong with the database ***/
$message = 'We are unable to process your request. Please try again later"';
}
}
?>
<!DOCTYPE HTML>
<!--
Strongly Typed 1.1 by HTML5 UP
html5up.net | @n33co
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
<head>
<title>Wedding Website</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="viewport" content="width=1040" />
<link rel="shortcut icon" href="favicon.ico">
<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600|Arvo:700" rel="stylesheet" type="text/css" />
<!--[if lte IE 8]><script src="js/html5shiv.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script src="js/jquery.dropotron.min.js"></script>
<script src="js/config.js"></script>
<script src="js/skel.min.js"></script>
<script src="js/skel-panels.min.js"></script>
<noscript>
<link rel="stylesheet" href="css/skel-noscript.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/style-desktop.css" />
</noscript>
</head>
<body class="homepage">
<!-- Header Wrapper -->
<div id="header-wrapper">
<!-- Header -->
<div id="header" class="container">
<!-- Logo -->
<h1 id="logo">Our Wedding Website</h1>
<p>Welcome to our wedding website. Here you'll find a bit about the Church and some local accommodation. You'll also find our gift list where you can browse and choose what to get, so two people don't end up buying the same!</p>
<!-- Nav -->
<?php
include('navbar.php');
?>
</div>
</div>
<?php
if(isset( $_SESSION['user_id'] )) {
?>
<!-- Features Wrapper -->
<div id="features-wrapper">
<!-- Features -->
<section id="features" class="container">
<header>
<h2>We're getting<strong> married</strong>!</h2>
</header>
<div class="row">
<div class="4u">
<!-- Feature -->
<section>
<a href="#" class="image image-full"><img src="images/01.png" alt="" /></a>
</section>
</div>
<div class="4u">
<!-- Feature -->
<section>
<a href="#" class="image image-full"><img src="images/04.png" alt="" /></a>
</section>
</div>
<div class="4u">
<!-- Feature -->
<section>
<a href="#" class="image image-full"><img src="images/03.png" alt="" /></a>
</section>
</div>
</div>
</section>
</div>
<!-- Banner Wrapper -->
<div id="banner-wrapper">
<div class="inner">
<!-- Banner -->
<section id="banner" class="container">
<p>To have and to hold</p>
</section>
</div>
</div>
<?php
} else {
?>
<div id="main-wrapper">
<div id="main" class="container">
<form action="index.php" method="post">
<table class="login">
<tr><td class="left">Password:</td><td><input type="password" id="password" name="password" value="" maxlength="20" /></td></tr>
<tr><td class="left"></td><td><button type="submit">Submit</button></td></tr>
</table>
</div>
</div>
<?php
}
?>
<?php
include('footer.php');
?>
</body>
</html>