-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchats.php
executable file
·135 lines (127 loc) · 3.05 KB
/
chats.php
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
<?php
session_start();
include 'dbconnect.php';
//$_SESSION['touser_name']="";
?>
<html>
<head>
<style>
body{
margin:0;
padding:0;
background:#FFFFFF;
background-size:cover;
background-position: center;
}
textarea{
font-family: 'Lato', 'Helvetica Neue', Arial, Helvetica, sans-serif;
margin: 0em;
outline: none;
line-height: 1.21428571em;
padding: 0.67857143em 1em;
font-size: 1em;
background: #FFFFFF;
border: 1px solid rgba(34, 36, 38, 0.15);
color: rgba(0, 0, 0, 0.87);
border-radius: 0.28571429rem;
box-shadow: 0em 0em 0em 0em transparent inset;
}
button:hover {
background-color: #CACBCD;
background-image: none;
box-shadow: 0px 0px 0px 1px transparent inset, 0px 0em 0px 0px rgba(34, 36, 38, 0.15) inset;
color: rgba(0, 0, 0, 0.8);
}
button {
cursor: pointer;
display: inline-block;
min-height: 1em;
outline: none;
border: none;
vertical-align: baseline;
background: #E0E1E2 none;
background-color: rgb(224, 225, 226);
background-image: none;
color: rgba(0, 0, 0, 0.6);
font-family: 'Lato', 'Helvetica Neue', Arial, Helvetica, sans-serif;
margin: 0em 0.25em 0em 0em;
padding: 0.78571429em 1.5em 0.78571429em;
text-transform: none;
text-shadow: none;
font-weight: bold;
line-height: 1em;
font-style: normal;
text-align: center;
text-decoration: none;
border-radius: 0.28571429rem;
}
.message{
box-sizing:border-box;
border:1px solid black;
width:500px;
}
.text-msg{
position:fixed;
z-index:4;
bottom:0;
}
</style>
</head>
<?php
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if(isset($_POST['chat'])||isset($_SESSION['touser_name'])){
if(!isset($_POST['userchat'])&&!isset($_SESSION['touser_name'])){
header("Location:home.php");
}
$fromuser_name=$_SESSION['username'];
if(!empty($_SESSION['touser_name'])){
//echo "hi"; die();
$touser_name=$_SESSION['touser_name'];
}
else{
$touser_name=$_POST['userchat'];
$_SESSION['touser_name']=$touser_name;
}
$touser_name=test_input($touser_name);
//echo $touser_name."Gtu"; die();
$fromuser_name=test_input($fromuser_name);
$sql="SELECT * FROM kunal_message where (touser_name='$touser_name' and fromuser_name='$fromuser_name') || (touser_name='$fromuser_name' and fromuser_name='$touser_name');";
//echo $sql; die();
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result)>0){
while($row=mysqli_fetch_assoc($result)){
?>
<div class=message>
To:<?php echo $row['touser_name']?><br>
From:<?php echo $row['fromuser_name']?><br>
Time:<?php echo $row['time']?><br>
<b>Message:<?php echo $row['msg'] ?></b>
</div>
<?php
}
}
else{
echo "NO CHATS";
}
?>
<div class="text-msg">
<form action="sendmsg.php" method="POST">
To:<?php echo $touser_name ?><br>
Message<br>
<textarea placeholder="message" name="msg">
</textarea>
<button type="submit" name="sendmsg" value="sendmsg">SEND</button>
</form>
<a href="home.php"> HOME </a>
</div>
<?php
}
else{
header("Location:home.php");
}
?>