-
Notifications
You must be signed in to change notification settings - Fork 0
/
club.php
78 lines (71 loc) · 2.61 KB
/
club.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
<!DOCTYPE html>
<?php
session_start();
?>
<html>
<head>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<script src="/js/jquery-1.11.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">HopkinsClubs</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<?php
if (!isset($_SESSION["username"]) || !isset($_SESSION["password"])) {
echo "<li><a href='/login.html'>Log In</a></li>";
}
else {
echo "<li><a href='/logout.php'>Log Out " . $_SESSION["username"] . "</a></li>";
}
?>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<center>
<?php
$con=mysqli_connect("localhost","root","root","HopkinsClubs");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$id = $_GET['id'];
$result = mysqli_query($con, "SELECT * FROM Clubs WHERE id='$id'");
$row = mysqli_fetch_array($result);
echo "<img src='" . $row{'imgurl'} . "'style='width:500px;height:200px'></img>";
echo "<h1>" . $row{'name'} . "</h1>";
echo "<p>" . $row{'description'} . "</p>";
echo "</center>";
$result = mysqli_query($con,"SELECT * FROM Posts WHERE pageid='$id'");
while($row = mysqli_fetch_array($result)) {
echo "<h3>" . $row{'title'} . "</h3><h6>By: " . $row{'author'} . "</h6><p>" . $row{'post'} . "</p><br>";
}
//check user account for posting
if (isset($_SESSION["username"]) || isset($_SESSION["password"])) {
echo "<form action='post.php' method='post'>
Title: <input type='text' name='title' />
<br />
<p>Post:</p>
<textarea name='post'></textarea>
<br />
<input type='submit' value='Post'/><input style='visibility: hidden;' type='text' name='id' value='" . $id . "' />
</form>";
}
mysqli_close($con);
?>
</body>
</html>