Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.46 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.  
  5. <?php
  6. $servername = "localhost";
  7. $username = "root";
  8. $password = "qweasd123";
  9.  
  10. // Create connection
  11. $conn = new mysqli($servername, $username, $password);
  12.  
  13. // Check connection
  14. if ($conn->connect_error) {
  15.     die("Connection failed: " . $conn->connect_error);
  16. }
  17. echo "Connected successfully";
  18. ?>
  19.  
  20. <script>
  21. function handleKeyPress(e){
  22.   var key=e.keyCode || e.which;
  23.   if (key==13){
  24.      var txt = document.getElementById("text").value;
  25.      var div = document.getElementById("chatdiv");
  26.      div.innerHTML = div.innerHTML + "</br>" + txt;
  27.      document.getElementById("text").value='';
  28.      div.scrollTop = div.scrollHeight;
  29.  
  30.  
  31.   }
  32.  
  33.     $cmd = "INSERT INTO CHAT (ip,time, text)
  34.     VALUES ('Glenn',CURRENT_TIMESTAMP.get,'33')"
  35.     ;
  36.     mysql_real($conn,$cmd);
  37.     ?>
  38. }
  39.  
  40.  
  41. </script>
  42.  
  43. <style>
  44. .chatdiv {
  45.     border-radius: 25px;
  46.     border: 2px solid #8AC007;
  47.     padding: 20px;
  48.     width: 500px;
  49.     height: 150px;
  50.     overflow-x: hidden;
  51.     overflow-y: visible;
  52. }
  53. .enterbox {
  54.    border-radius: 25px;
  55.    border: 2px solid #8AC007;
  56.    padding: 20px;
  57.    width: 500px;
  58.    height: 20px;
  59. }
  60. </style>
  61. </head>
  62. <body>
  63.  
  64. <div id="chatdiv" class="chatdiv">Tohle je div se zaoblenyma rohama, tady by se mohl zobrazovat chat ???</div>
  65. <br><br>
  66. <div class="enterbox"><input type="text" id="text" value="text zprávy" maxlength="500" style="width: 500px" onkeypress=handleKeyPress(event)></div>
  67. </body>
  68. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement