-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposts.pro.php
More file actions
107 lines (96 loc) · 3.79 KB
/
posts.pro.php
File metadata and controls
107 lines (96 loc) · 3.79 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
<?php
session_start();
if (array_key_exists("user", $_SESSION) & isset($_GET['TID'])) {
require_once('./mydb/databaseManager/DBEnter.db.php');
// including the head of the HTML and data
include("./layouts/header.php");
$TID = $_GET['TID'];
?>
<!-- Jquery for thread form -->
<script>
$(document).ready(function() {
$('#postTable').load("./mydb/posts/postContent.show.php?TID=<?php echo $TID; ?>");
$('[data-toggle="popover"]').popover();
});
$(document).ready(function() {
$("#postUpdate").click(function () {
$('#spinner').addClass('spinner-border spinner-border-sm');
$.post("./mydb/posts/createPost.db.php", {
TID: $("#TID").val(),
title: $("#title").val(),
info: $("#info").val()
},
function (data, status) {
$('#spinner').removeClass('spinner-border spinner-border-sm');
$("#displaySuccess").html(data);
if (status === "success") {
$('#myModal').modal('toggle');
$('#postTable').load("./mydb/posts/postContent.show.php?TID=<?php echo $TID; ?>");
console.log('hidden and reloaded');
} else {
$('#myModal').modal('toggle');
}
console.log(data, status);
console.log('Issue');
}
)
});
});
</script>
<h1 class="text-center">Posts</h1>
<section class="container">
<div class="row">
<div class="col-sm-3 text-center">
<div class="container">
<h2>Creat Post</h2>
<!-- Button to Open the Modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Creat Post</button>
<!-- where the jQuery data should go -->
<div id="displaySuccess">
<p>submit message</p>
</div>
<!-- The Modal -->
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div>
<div id="postForm" class="login-form hidden" role="form">
<div class="modal-body">
<!-- hidden input for TID -->
<input type="hidden" id="TID" name="TID" value="<?php echo $TID;?>">
<h4 style="float: left;">Title of the Post</h4>
<input type="text" id="title" name="title" class="form-control" placeholder="Title" required autofocus>
<h4 style="float: left;">Information of the Post</h4>
<input type="text" id="info" name="info" class="form-control" placeholder="Information" required autofocus>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button class="btn btn-primary" style="!important; width: 10em;" id="postUpdate">Create Post <span style="height:15px; width:15px; margin-right: 10px;" id="spinner"></span></button>
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-9 text-center" id="postTable">
</div>
</div>
</section>
<script>
</script>
<?php
include("./layouts/footer.php");
}else{
header('location: index.php?pageaccess=forbidden');
exit;
}
?>