forked from muhammed-salman/usermsg
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessages.php
More file actions
71 lines (68 loc) · 3.13 KB
/
Copy pathmessages.php
File metadata and controls
71 lines (68 loc) · 3.13 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
<?php
/*
This Work is Licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
You are free to:
Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms:
Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
NonCommercial — You may not use the material for commercial purposes.
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
Notices:
You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
Author: Muhammed Salman Shamsi
Created on: Jun 21, 2017
*/
?>
<html>
<head>
<?php require_once 'header.php' ?>
<title>User Messenger: Messages</title>
</head>
<body>
<?php require_once 'navigationbar.php'?>
<div class="container">
<?php if($loggedin){
if($_POST){
insertMsg();
if(!empty($_POST['user']))
$user= sanitizeString ($_POST['user']);
// else {
// $user=$_SESSION['userid'];
// echo "hello";
// }
}
$result= queryMysql("Select * from Messages where userid='$user' order by time_stamp");
?>
<h2 class="text-center">Message Board</h2>
<?php if($_SESSION[user]==$user){ ?>
<form method="post" action="messages.php">
<textarea class="message-post" rows="5" name="post_message" placeholder="What is in your mind? Share with us..."></textarea>
<button type="submit" id="msgSubmit" class="btn btn-primary col-lg-3 col-md-4 col-sm-10">Post</button>
</form>
<?php
}
else{
echo '<h4 class="text-center">'.$user.' \'s Messages </h4>';
}
if(mysqli_num_rows($result)>0){
while($row=mysqli_fetch_array($result)){
echo '<div class="message col-lg-6 col-md-8 col-sm-10">'.$row['msg'].
'<div class="text-right">'.date('d-m-Y H:i:s', strtotime($row['time_stamp'])).'</div>';
if($_SESSION['role']==1)
echo '<button class="btn btn-delete" id="'.$row['idMsg'].'">Delete</button>';
echo '</div>';
}
}
else{
echo '<div class="message alert alert-info col-lg-12 col-md-12 col-sm-12">No Message to display!</div>';
}
}
else{
echo '<div class="alert alert-danger">Please LogIn to use System</div>';
header("Refresh: 2; url=login.php");
}
echo '<br><br>';
require_once 'footer.php';