Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "qweasd123";
- // Create connection
- $conn = new mysqli($servername, $username, $password);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- echo "Connected successfully";
- ?>
- <script>
- function handleKeyPress(e){
- var key=e.keyCode || e.which;
- if (key==13){
- var txt = document.getElementById("text").value;
- var div = document.getElementById("chatdiv");
- div.innerHTML = div.innerHTML + "</br>" + txt;
- document.getElementById("text").value='';
- div.scrollTop = div.scrollHeight;
- }
- $cmd = "INSERT INTO CHAT (ip,time, text)
- VALUES ('Glenn',CURRENT_TIMESTAMP.get,'33')"
- ;
- mysql_real($conn,$cmd);
- ?>
- }
- </script>
- <style>
- .chatdiv {
- border-radius: 25px;
- border: 2px solid #8AC007;
- padding: 20px;
- width: 500px;
- height: 150px;
- overflow-x: hidden;
- overflow-y: visible;
- }
- .enterbox {
- border-radius: 25px;
- border: 2px solid #8AC007;
- padding: 20px;
- width: 500px;
- height: 20px;
- }
- </style>
- </head>
- <body>
- <div id="chatdiv" class="chatdiv">Tohle je div se zaoblenyma rohama, tady by se mohl zobrazovat chat ???</div>
- <br><br>
- <div class="enterbox"><input type="text" id="text" value="text zprávy" maxlength="500" style="width: 500px" onkeypress=handleKeyPress(event)></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement