-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.php
More file actions
38 lines (35 loc) · 1.08 KB
/
chat.php
File metadata and controls
38 lines (35 loc) · 1.08 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
<?php
include 'header.php';
if(isset($_SESSION['username'])): ?>
<div class="wrapper">
<div class="container">
<div class="row">
<div class="col-md-6">
<form method="POST" name="chat" autocomplete="off">
<textarea name="message" class="form-control" id="message-box" rows="7"></textarea>
<a class="btn btn-primary" id="send">Send</a>
</form>
</div>
<div class="col-md-6">
<div class="chat">
<p class="message-buffer"></p>
</div>
</div>
</div>
</div>
</div>
<?php else: echo '<div class="container"><h1 style="color:red;">You have to sign up first!</h1></div>';endif;?>
<script type="text/javascript">
$(document).ready(function(){
$('#send').click(function(){
var msg = $('#message-box').val();
if(msg != ''){
$.post('ajax/main_chat.php',{msg:msg},function(data){
//console.log(data);
$('p:last-child').html(data);
$('.chat').append("<p></p>");
});
}else{alert('Please type something!');}
});
});
</script>