-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathchat2.php
108 lines (90 loc) · 2.65 KB
/
chat2.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
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<center>
<div id="limit">
<center >
<form action="chatinsert.php" method="POST" class="chatinput" >
<input type="text" name="username" value="amol" readonly style='border-radius:50px;border:1px solid green;display:none;'><br><br><br>
<input type="text" name="msg" id="msg" placeholder=" type your message here"><br><br>
<button type="submit" class="btn btn-lg btn-success" style="border-radius:50%;"><span class="glyphicon glyphicon-send"></span></button>
</form>
<style>
.chatmsg
{
background-color: #075bff;
border: 1px solid #075bff;
border-radius: 10px;
height:auto;
width:20%;
padding: 8px;
color: red;
}
.adchatmsg
{
background-color: #5FCF80;
border: 1px solid #5FCF80;
border-radius: 10px;
height:auto;
width:20%;
padding: 8px;
color: white;
}
#chats
{
text-align: center;
width:50%;
height: auto;
border-radius: 30px;
background: url('wall.png');
padding-top: 10px;
min-height: 80%;
}
#msg
{
height:80px;
width:700px;
border:1px solid green;
border-radius: 50px;
background-color: lightyellow;
}
#limit
{
background-image:url('wall.jpg');
}
</style>
<script>
function displaychat()
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
document.getElementById("chats").innerHTML = this.responseText;
}
}
xmlhttp.open("GET", "chatdisplay.php", true);
xmlhttp.send();
}
setInterval(displaychat,100);
</script>
<div id="chats"></div></center>
<?php
if($_SERVER['REQUEST_METHOD']=="GET"){
$localhost = "localhost";
$usernamew = "root";
$passwordw = "";
$db = "expdb";
$conn = mysqli_connect($localhost,$usernamew,$passwordw,$db);
if(!$conn){
echo "Connection error";
}
else{
$sql = "UPDATE counter SET visit=visit+1 WHERE id = 3";
$result = mysqli_query($conn,$sql);
}
}
?>