Advertisement
coderboy

ChatApp - index

May 20th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.16 KB | None | 0 0
  1. <?php
  2. $user = $_GET["user"];
  3. ?>
  4. <html>
  5. <head>
  6. <style>
  7. .display {
  8.     background-color: #F0FFFF;
  9.     width: 80%;
  10.     position: relative;
  11.     left: 10%;
  12.     border: 1px solid black;
  13.     height: 80%;
  14. }
  15. .tb {
  16.     width:100%;
  17.     height: 5%;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <h1>Instant Messanger</h1>
  23. <div class="display">
  24. <p id="content"></p><br>
  25. </div>
  26. <div class="contentbar">
  27. <input class="tb" type="text" id="msg">
  28. <button onclick="send()">Send</button>
  29. </div>
  30. </body>
  31. </html>
  32. <script>
  33. function send() {
  34.     var msg = document.getElementById("msg").value;
  35.     var user = "<?php echo $user; ?>";
  36.     var xmlhttp = new XMLHttpRequest();
  37.     xmlhttp.open("GET", "backend.php?mode=send&user=" + usr + "&msg=" + msg, true);
  38.     xmlhttp.send();
  39. }
  40. function get() {
  41.     var xmlhttp = new XMLHttpRequest();
  42.         xmlhttp.onreadystatechange = function() {
  43.             if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  44.                document.getElementById("content").innerHTML = xmlhttp.responseText;
  45.             }
  46.         };
  47.         xmlhttp.open("GET", "backend.php?mode=get", true);
  48.         xmlhttp.send();
  49. }
  50. setInterval(get, 1000);
  51. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement