Advertisement
Guest User

Chat Code

a guest
Aug 27th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.67 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script>
  4.     function loadXMLDoc(){
  5.         var xmlhttp = new XMLHttpRequest();
  6.         xmlhttp.onreadystatechange=function() {
  7.             if (xmlhttp.readyState==4 && xmlhttp.status==200) {
  8.                 document.getElementById("chatFenster").innerHTML=xmlhttp.responseText;
  9.             }
  10.         }
  11.         xmlhttp.open("GET","refresh.php",true);
  12.         xmlhttp.send();
  13.     }
  14.     setInterval(loadXMLDoc, 1500);
  15.    
  16.     function clearText() {
  17.         document.getElementById('text').value = '';
  18.     }
  19. </script>
  20. </head>
  21. <body onload="loadXMLDoc();" style="text-align: center;">
  22. <?php
  23. include("helper.php");
  24. $database = connect();
  25. if (isset ($_SESSION['userID'])){
  26.     $user = getUser($database, $_SESSION['userID']);
  27. }
  28. if (isset($user)){
  29.     if ($user != NULL){
  30.     if (isset ($_POST['klasse'])){
  31.         $_SESSION['klasse'] = $_POST['klasse'];
  32.         }
  33.         ?>
  34.         <h2>Chat</h2>
  35.         <div id="chatFenster" style="overflow:auto; height:700px; width:500px;text-align: left; margin-left: auto; margin-right: auto;">
  36.        
  37.         </div>
  38.         <br>
  39.         <br>
  40.         <form name="senden" action="senden.php" method="post">
  41.         <textarea name="text" id="text" style='height:30px; width:200px;'></textarea>
  42.         <input type="submit" name="senden" value="senden" style='height:30px; width:70px; position: relative; top: -7px;'>
  43.         </form>
  44.         <form action="upload.php" enctype="multipart/form-data" method="post">
  45.         <input type="file" name="file">
  46.         <input type="submit" name="upload">
  47.         </form>
  48.         <button onclick="loadXMLDoc();">Refresh</button>
  49.         <button onclick="clearText()">clear</button>
  50.         <?php
  51.     } else {
  52.         echo "Du hast nicht die Befugnis!";
  53.         header("refresh:5;index.php");
  54.     }
  55. } else {
  56.     echo "Du hast nicht die Befugnis!";
  57.     header("refresh:5;index.php");
  58. }
  59. ?>
  60. </body>
  61. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement