-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththreadslist.php
More file actions
156 lines (132 loc) · 7.41 KB
/
threadslist.php
File metadata and controls
156 lines (132 loc) · 7.41 KB
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
146
147
148
149
150
151
152
153
154
155
156
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="./res/logo4.png">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- Custom css -->
<link rel="stylesheet" href="./styles/indexPage.css">
<title>Reflect Forum</title>
</head>
<body>
<?php include './partials/_header.php' ?>
<?php include './partials/_dbconnect.php' ?>
<?php
$id = $_GET['catid'];
$sql = "SELECT * FROM `categories` WHERE `category_id` = $id;";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$catTitle = $row['category_title'];
?>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$problem_title = $_POST['problem_title'];
$problem_desc = $_POST['problem_desc'];
$user_id = $_SESSION['sno'];
$problem_title = str_replace("<", "<", $problem_title);
$problem_title = str_replace(">", ">", $problem_title);
$problem_desc = str_replace("<", "<", $problem_desc);
$problem_desc = str_replace(">", ">", $problem_desc);
$sql = "INSERT INTO `threads` (`thread_id`, `thread_title`, `thread_desc`, `thread_cat_id`, `thread_user_id`, `timestamp`) VALUES (NULL, '$problem_title', '$problem_desc', '$id', '$user_id', current_timestamp());";
$result = mysqli_query($conn, $sql);
echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong>Success ! </strong> Your thread has been posted successfully. Please wait for the community to respond.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
?>
<!-- Rules -->
<div class="container-fluid">
<div class="row">
<div class="col order-first figure">
<img src="./res/threadsListImg2.gif" class=" g-col-md-4 figure-img img-fluid rounded" alt="...">
</div>
<div class="col order-last m-2 container-md border border-secondary shadow p-2 mb-5 bg-body rounded">
<div style="background-color:#25334d; height: 415px;" >
<h4 style="color:#a2acbd" class="text-center fs-3 my-2 style=color:red"s>Rules for the <?php echo $catTitle ?> </h4>
<ul class="p-4 list-group">
<li style="background-color:#a2acbd;" class="list-group-item">No Spam / Advertising / Self-promote in the forums</li>
<li style="background-color:#a2acbd;" class="list-group-item">Do not post copyright-infringing material</li>
<li style="background-color:#a2acbd;" class="list-group-item">Do not post “offensive” posts, links or images</li>
<li style="background-color:#a2acbd;" class="list-group-item">Remain respectful of other members at all times</li>
<li style="background-color:#a2acbd;" class="list-group-item">Do not offer to pay for help</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Ask Question section -->
<?php
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true) {
echo '<div class="container my-3">
<p class="fs-3">Ask your Question </p>
<form action="' . $_SERVER['REQUEST_URI'] . '" method="POST">
<div class="mb-3">
<label for="problem_title" class="form-label">Problem Title</label>
<input type="text" class="form-control" id="problem_title" name="problem_title" aria-describedby="emailHelp">
<div id="problem_title_help" class="form-text">Keep the title short and crisp</div>
</div>
<div class="mb-3">
<label for="problem_desc" class="form-label">Elaborate the problem</label>
<textarea class="form-control" id="problem_desc" name="problem_desc" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-danger">POST</button>
</form>
</div>';
} else {
echo '<div style="color:#05399c;" class="text-center link-warning fs-4" >Please log in to ask questions ! </div> </div>';
}
?>
<div class="container-fluid">
<p style="color:#05399c;" class="fs-3 text-center">Browse Questions for <?php echo $catTitle ?></p>
<div class="container-xl my-2">
<div class="container-md rounded">
<!-- Questions here -->
<?php
$id = $_GET['catid'];
$sql = "SELECT * FROM `threads` WHERE `thread_cat_id` = $id;";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) == 0)
echo '<div class="text-center link-danger fs-3" >No threads found ! </div>';
else {
while ($row = mysqli_fetch_assoc($result)) {
$timestamp = $row['timestamp'];
$thread_id = $row['thread_id'];
$title = $row['thread_title'];
$desc = $row['thread_desc'];
$thread_user_id = $row['thread_user_id'];
//fetching user details
$sql2 = "SELECT user_email FROM `users` WHERE sno='$thread_user_id'";
$result2 = mysqli_query($conn, $sql2);
$row2 = mysqli_fetch_assoc($result2);
echo ' <div class="card p-2 m-3">
<h5 class="card-header" style="background-color:#a2acbd;" style="color:#05399c;">Posted by ' . $row2['user_email'] . ' : ' . $timestamp . '</h5>
<div class="card-body">
<h5 class="card-title">' . $title . '</h5>
<p class="card-text">' . substr($desc, 0, 30) . '...</p>
<a href="thread.php?threadid=' . $thread_id . '" class="btn btn-warning" style="color:white;">See Discussions</a>
</div>
</div>';
}
}
?>
</div>
</div>
</div>
<?php include './partials/_footer.php' ?>
<!-- Optional JavaScript; choose one of the two! -->
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<!-- Option 2: Separate Popper and Bootstrap JS -->
<!--
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
-->
</body>
</html>