-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.php
87 lines (82 loc) · 2.5 KB
/
header.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
<?php
session_start();
require 'dbconnect.php';
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $title;?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles/screen.css" media="screen and (min-width: 700px)"/>
<link rel="stylesheet" href="styles/mobile.css" media="screen and (max-width: 700px)" />
<link href="http://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Damion" rel="stylesheet" type="text/css">
<script src="scripts/jquery.js"></script>
</head>
<body>
<header>
<h1>Jobify</h1>
<?php
if(isset ($_SESSION['loggedin'])){
if(($_SESSION['loggedin'])== true){
echo 'Welcome back <br/> <a href="logout.php">Logout</a>';
}
}
else{
if(isset ($_POST['login'])){
$stmt = $pdo->prepare('SELECT * FROM users WHERE mail = :mail AND pass = :password');
$criteria = [
'mail' => $_POST['mail'],
'password' => $_POST['pwd']
];
$stmt->execute($criteria);
if ($stmt->rowCount() > 0) {
$_SESSION['loggedin'] = true;
while ($row = $stmt->fetch()) {
echo 'Welcome back ' . $row['fname']. ' <br/> <a href="logout.php">Logout</a>';
$_SESSION['email']=$row['mail'];
$_SESSION['admin']=$row['admin'];
}
}
else {
echo 'Sorry, your username and password could not be found';
}
}
else{
?>
<div id="loginContainer" align="right">
<form id="loginform" method="post">
<label for "mail">E-mail adress: </label>
<input id="mail" name="mail" type="email" "required"/>
<br/>
<label for "pass">Password: </label>
<input id="pass" name="pwd" type="password" "required"/>
<br/>
<input type="submit" name="login" value="Login"/>
<br/>
<span>Don't have an account?</span>
<a href="register.php">Register now</a><br/>
<span>admin login: [email protected] password: abcd</span>
</form>
</div>
<?php
}
}
?>
<div id="searchContainer">
<form id="searchform" action="jobs.php" method="post">
<input id="searchbar" name="searchkey" type="text" placeholder="Find jobs..." "required" autocomplete="off">
</form>
</div>
</header>
<nav align="center">
<a href="index.php">Home </a><a href="jobs.php">Jobs </a>
<?php
if(isset($_SESSION['admin'])){
if($_SESSION['admin'] == 'y'){
echo'<a href="admin.php">Admin</a>';
}
}
?>
</nav>
<main>