-
Notifications
You must be signed in to change notification settings - Fork 0
/
PHY102.php
86 lines (74 loc) · 3 KB
/
PHY102.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
<?php
SESSION_START();
require 'info.php';
?>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Clear It - Discussion Forum">
<meta name="keywords" content="IITK, Clear It">
<meta name="viewport" content="width=device-width initial-scale=1.0">
<title>DISCIT :PHY102</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand">DISCIT</a>
</div>
<?php
//Checking if user signed in
if($_SESSION['sign_in']){
echo '<p class="navbar-text">WELCOME  '.$_SESSION['name'].'</p>
<ul class="nav navbar-nav">
<li><a href="leaderboard.php">LEADER BOARD</a></li>
<li><a href="profile.php">VIEW PROFILE</a></li>
<li><a href="search.php">SEARCH</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="logout.php"><span class="glyphicon glyphicon-log-in"></span> LOG OUT</a></li>
</ul>';
?>
</div>
</nav>
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li class="active"><a href="newpost.php">NEW POST</a></li>
</div>
</nav>
<?php
//Retrieving id of the thread, content of the thread, name of the author and date on which thread was created from the database.
$sql="SELECT op.op_id,op.op_content,user_info2.name,op.op_date FROM op LEFT JOIN user_info2 ON op.op_author=user_info2.userid WHERE op.op_subject='PHY102'";
$result=mysqli_query($info,$sql);
if(!$result){
echo 'Original Post could not be retrieved';
}
else if(mysqli_num_rows($result) == 0){
echo 'No Posts for this subject';
}
else{
//Displaying date on which thread was created, Name of the author of the thread and thread content in a tabular form.
echo '<div class="container" style="width:100%;">
<table class="table table-condensed">
<thead><tr><th>Created At</th><th>Posted By</th><th>Post</th></tr></thead>';
while($row=mysqli_fetch_assoc($result)){
echo '<tbody><tr>';
echo '<td>'.date('d-m-Y',strtotime($row['op_date'])).'</td>';
echo '<td>'.$row['name'].'</td>';
echo '<td><h4><a href="op.php?id='.$row['op_id'].'">'.$row['op_content'].'</a></h4></td>';
echo '<td></td>';
echo '</tr>';
}
echo '</tbody></table></div>';
}
}
//Giving JavaScript alert if user not signed in.
else{
echo '<script type="text/javascript"> alert("YOU ARE NOT LOGGED IN...PLEASE FIRST LOGIN.")</script>';
echo "<script> location.href='login.php'; </script>";
}
?>
</body>
</html>