34 lines
1.2 KiB
PHP
34 lines
1.2 KiB
PHP
<?php
|
|
$id=$_GET['id'];
|
|
//$id1=$_SESSION['id']; COMMENTED THIS AS I AM NOT IN SESSION. HARDCODED IT IN THE FORM AS VALUE 5
|
|
?>
|
|
<html>
|
|
<head>
|
|
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<form method="post" class="msgfrm" id="msgfrm">
|
|
<input type="hidden" value="<?php echo $_GET['id']; ?>" name="rcvrid" id="rcvrid">
|
|
<input type="hidden" name="senderid" id="senderid" value="5" >
|
|
<div class="msgdiv" id="chatbox"></div>
|
|
<div class="textdiv">
|
|
<input type="text" name="msg" id="msg" class="textmsg">
|
|
<input type="submit" value="Send" >
|
|
</div>
|
|
</form>
|
|
<script>
|
|
$("#msgfrm").on("submit", function(event) {
|
|
event.preventDefault();
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "msg_save.php",
|
|
data: $(this).serialize(),
|
|
success: function(data) {
|
|
$("#chatbox").append(data+"<br/>");//instead this line here you can call some function to read database values and display
|
|
},
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|