-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
108 lines (85 loc) · 2.14 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
<html>
<head>
<meta charset="utf-8">
<title>handkerchief</title>
<link rel="stylesheet" type="text/css" href="main.css">
<style>
#main {height: 100%;}
.movie
{
width: 240px;
float: left;
margin: 10px 0px;
margin-right: 30px;
cursor: pointer;
}
.movie img
{
width: 240px;
height: 340px;
}
.movie:hover
{
opacity: 0.85;
}
</style>
</head>
<body>
<?php
include 'db.php';
session_start();
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$_SESSION["url"] = filter_var($url, FILTER_VALIDATE_URL);
$username = @$_SESSION["username"];
?>
<div id="header">
<div id="logo">
<a href='index.php'>handkerchief</a>
</div>
<div id="login">
<?php
if(@$username) {
echo "
<a>Profile</a>
<div id='menu'>
<span id='username'>$username</span>
<a href='bookedtickets.php'>Booked Tickets</a>
<a href='logout.php'>Logout</a>
</div>";
}
else {
echo "<a href='login.php'>Login</a>";
}
?>
</div>
</div>
<div id="main">
<?php
$sql = "SELECT movie_id, poster FROM movie ORDER BY release_date DESC";
if($result = mysqli_query($conn, $sql)) {
while($row = mysqli_fetch_assoc($result)) {
echo "
<div class='movie' id='".$row['movie_id']."' onclick='getMovieId(this.id)'>
<img src='".$row['poster']."'>
</div>";
}
}
else {
echo "<p>ERROR: Failed to execute query $sql ".mysqli_error($conn)."</p>";
}
mysqli_close($conn);
?>
<form id='movieForm' method='get' action='moviepage.php' style='display:none'>
<input type="text" name='movieId' id='movieId'>
</form>
<div class="clear"></div>
</div>
<div id="footer"></div>
<script>
function getMovieId(movieId) {
document.getElementById('movieId').value = movieId;
document.getElementById('movieForm').submit();
}
</script>
</body>
</html>