-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshowthread.php
More file actions
193 lines (148 loc) · 6.42 KB
/
showthread.php
File metadata and controls
193 lines (148 loc) · 6.42 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<title>iDiscuss with PVS</title>
</head>
<body>
<?php include 'css/connection.php' ?>
<?php include 'css/navbar.php' ?>
<!-- PHP FOR FETCHING COMMENT FROM THE DATABASE
--> <?php
$id = $_GET['threadid'];
$sql = "select * from `thread` Where thread_id = $id";
$result = mysqli_query($conn, $sql);
$noques = true;
while ($row = mysqli_fetch_assoc($result)) {
$noques = false;
$tittle = $row['thread_tittle'];
$threaddesc = $row['thread_description'];
$threadid=$row['thread_user_id'];
$sqle= "SELECT usename FROM `usess` WHERE Sno='$threadid'";
$result2 = mysqli_query($conn, $sqle);
$row2= mysqli_fetch_assoc($result2);
$postby=$row2['usename'];
}
?>
<!-- PHP FOR INSERTING COMMENT TO THE DATABASE -->
<?php
$showAlert=false;
$showError=false;
$METHOD=$_SERVER['REQUEST_METHOD'];
if($METHOD=='POST'){
if (isset($_SESSION['loggedinn']) && $_SESSION['loggedinn'] = true) {
$commentbyuser=$_POST['commentdecription'];
$id=$_GET['threadid'];
$cmentby=$_POST['sno'];
if(!$commentbyuser==""){
$commentbyuser= str_replace("<", "<", "$commentbyuser");
$commentbyuser= str_replace(">", ">", "$commentbyuser");
$showAlert=true;
$sql= "INSERT INTO `comments` (`comment_tittle`, `thread_id`,`comment_by`, `comment_time`) VALUES ('$commentbyuser', '$id','$cmentby', current_timestamp())";;
$result=mysqli_query($conn,$sql);
}
else{
$showError="Plese write a comment to post";
}
}
else{
$showError="Please login to post a comment";
/* header("location: login.php"); */
}
}
?>
<!-- php for show a alert after submitting comment
--> <?php
if($showAlert){
echo ' <div class="alert alert-success alert-dismissible fade show" role="alert">
<strong>Congrates:-)</strong> Your comment is posted succesfully
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div> ';
}
if($showError){
echo ' <div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Sorry :-(</strong> '. $showError.'
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div> ';
}
?>
<div class="container">
<div class="jumbotron">
<h1 class="display-4"><?php echo $tittle ?></h1>
<p class="lead"><?php echo $threaddesc ?></p>
<hr class="my-4">
<p>Posted By:-<strong><?php echo $postby;?></strong></p>
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
</div>
</div>
<?php
echo '<div class="container">
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
<div class="form-group">
<label for="exampleFormControlTextarea1">Add a suggetion about problem</label>
<textarea class="form-control" id="decription" name="commentdecription"
placeholder="Release a helpful comment" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-success">Submit</button>';
if (isset($_SESSION['loggedinn']) && $_SESSION['loggedinn'] = true) {
echo'<input type="hidden" name="sno" value="'.$_SESSION["sno"].'">';
}
echo'</form>
</div>';
?>
<div class="container">
<h1 class="py-2">Discussion</h1>
<?php
$id = $_GET['threadid'];
$sql = "select * from `comments` Where thread_id=$id";
$result = mysqli_query($conn, $sql);
$noques = true;
while ($row = mysqli_fetch_assoc($result)) {
$noques = false;
$tittle = $row['comment_tittle'];
$tid = $row['comment_id'];
$threadid=$row['comment_by'];
$sqle= "SELECT usename FROM `usess` WHERE Sno='$threadid'";
$result2 = mysqli_query($conn, $sqle);
$row2= mysqli_fetch_assoc($result2);
/* $threaddesc = $row['thread_description']; */
echo ' <div class="media my-3">
<div class="media-body">
<a class="text-dark" ><h5 class="mt-0 text-black">' . $tittle . '</h5></a>
</div>
<p>Commented By:-<strong>'.$row2['usename'].'</strong></p>
</div>';
}
if ($noques) {
echo '<div class="jumbotron jumbotron-fluid">
<div class="container">
<h2>No Questions found</h2>
<p class="lead">Enter a question to ask</p>
</div>
</div>';
}
?>
</div>
<?php include 'css/footer.php' ?>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous">
</script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"
integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"
integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous">
</script>
</body>
</html>