forked from himanshukumar9/CHATBOX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconversation.php
More file actions
96 lines (91 loc) · 3.5 KB
/
conversation.php
File metadata and controls
96 lines (91 loc) · 3.5 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
<?php
include("configuration.php");
session_start();
if(!isset($_SESSION['email']))
{
header("location:index.php");
}
$email=$_SESSION['email'];
$sql=mysqli_query($al,"SELECT * FROM users WHERE email!='$email'");
$receiver=$_POST['user'];
$msg=$_POST['msg'];
$date=date('d-M-Y');
if($receiver==NULL || $msg==NULL)
{
}
else
{
mysqli_query($al,"INSERT INTO message(sender,receiver,msg,date) VALUES('$email','$receiver','$msg','$date')");
$info="Message Sent";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Conversation</title>
<link href="scripts/styleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<span class="heading">Private Conversation</span><span style="float:right"><a href="logout.php">
<img src="images/logout.png" height="50" width="100" /></a></span>
<hr style="border:6px dotted #63C;"/><br />
<br />
<div align="center">
<form method="post" action="">
<table class="table" cellpadding="4" cellspacing="4">
<tr><td class="tableHead" colspan="2" align="center" style="text-decoration:underline;">Send Messages</td></tr>
<tr><td class="info" colspan="2" align="center"><?php echo $info;?></td></tr>
<tr><td class="labels">Select User : </td><td><select name="user" class="fields" style="background-color:#051b18;">
<option disabled="disabled" selected="selected"> - - - - - - - - - </option>
<?php while($v=mysqli_fetch_array($sql))
{
?>
<option value="<?php echo $v['email'];?>"><?php echo $v['name'];?></option>
<?php } ?>
</select></td></tr>
<tr><td class="labels">Message : </td><td><textarea name="msg" class="fields" rows="2" cols="30" required="required"></textarea></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="SEND" class="commandButton" /></td></tr>
</table>
</form>
<br />
<br />
<?php
$r=mysqli_query($al,"SELECT * FROM message WHERE receiver='$email' ORDER BY id DESC");
?>
<table cellpadding="4" cellspacing="4" class="table">
<tr><td class="tableHead" align="center" colspan="2" style="text-decoration:underline;">Inbox</td></tr>
<?php while($t=mysqli_fetch_array($r))
{
$ee=$t['sender'];
$o=mysqli_query($al,"SELECT * FROM users WHERE email='$ee'");
$p=mysqli_fetch_array($o);
$recv=$p['nick'];
?>
<tr><td class="msg" style="font-size:12px;"><?php echo $t['msg'];?>
<span style="color:#F39;"> ( From <?php echo $recv;?> on <?php echo $t['date'];?>)</span>
</td><td><a href="deleteMessage.php?del=<?php echo $t['id'];?>" style="font-size:12px;">Delete</a></td></tr>
<?php } ?>
</table>
<br />
<?php
$r=mysqli_query($al,"SELECT * FROM message WHERE sender='$email' ORDER BY id DESC LIMIT 10");
?>
<table cellpadding="4" cellspacing="4" class="table">
<tr><td class="tableHead" align="center" colspan="2" style="text-decoration:underline;">Sent Messages</td></tr>
<?php while($t=mysqli_fetch_array($r))
{
$ee=$t['receiver'];
$o=mysqli_query($al,"SELECT * FROM users WHERE email='$ee'");
$p=mysqli_fetch_array($o);
$recv=$p['nick'];
?>
<tr><td class="msg" style="font-size:12px;"><?php echo $t['msg'];?><span style="color:#F39;"> ( To <?php echo $recv;?> on <?php echo $t['date'];?>)</span></td><td><a href="deleteMessage.php?del=<?php echo $t['id'];?>" style="font-size:12px;">Delete</a></td></tr>
<?php } ?>
</table>
<br />
<br />
<a href="home.php">BACK</a>
</div>
</body>
</html>