Guest User

Untitled

a guest
Jan 5th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.43 KB | None | 0 0
  1. <?php session_start(); ?>
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <META http-equiv="refresh" content="5;URL=chat.php">
  6.  
  7. <style>
  8. /* latin */
  9. @font-face {
  10.   font-family: 'VT323';
  11.   font-style: normal;
  12.   font-weight: 400;
  13.   src: local('VT323'), local('VT323-Regular'), url(VT323.woff2) format('woff2');
  14.   unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
  15. }
  16. *{
  17.     font-family: 'VT323', monospace!important;
  18. }
  19. html {
  20.   padding-bottom: 150px;
  21. }
  22. body {
  23.   width: 65vh;
  24.   margin: 20px auto;
  25.   background: #222;
  26.   color: #aaa;
  27.   font-size: 20px;
  28.   min-width: 820px;
  29.   overflow-y: scroll;
  30. }
  31. .post{
  32.   padding: 10px;
  33.   background-color: #333;
  34.   float:left;
  35.   clear: both;
  36.   width: 100%;
  37. }
  38. .message,.tripcode,.handle{
  39.   float:left;
  40. }
  41. .handle{
  42.   margin: 0 0px 0 0px;
  43.   width: 25%;
  44. }
  45. .tripcode{
  46.   color: gray;
  47.   margin-right: 10px;
  48.   width: 40px;
  49. }
  50. .message{
  51.   word-break: normal;
  52.   word-wrap: break-word;
  53.   width: 75%;
  54.   min-width: 400px;
  55.   clear: none;
  56.   float: right;
  57. }
  58. .name{
  59.   display: inline;
  60.   color:#999;
  61.   clear: none;
  62. }
  63. .user{
  64.   color:#aaa;
  65. }
  66. #shadow{
  67.   box-shadow: inset 0px 20px 20px -10px #222;
  68.   position: fixed;
  69.   width: calc(65% + 20px);
  70.   height: 30px;
  71.   top:-2px;
  72.   margin: 0 auto;
  73.   pointer-events: none;
  74.   background: none;
  75. }
  76. ::-webkit-scrollbar {
  77.   /* This is the magic bit */
  78.   display: none;
  79. }
  80. ::-moz-scrollbars-none{
  81.   display: none;
  82. }
  83.   </style>
  84. </head>
  85. <body>
  86. <!--<div id='shadow'></div>-->
  87. <?php
  88. $servername = "localhost";
  89. $username = "root";
  90. $password = "pass";
  91. $dbname = "name";
  92.  
  93. // Create connection
  94. $conn = new mysqli($servername, $username, $password, $dbname);
  95. // Check connection
  96. if ($conn->connect_error) {
  97.     die("Connection failed: " . $conn->connect_error);
  98. }
  99.  
  100. $sql = "SELECT clock, tripcode, handle, message FROM posts ORDER BY id DESC";
  101. $result = $conn->query($sql);
  102. if ($result->num_rows > 0) {
  103.     // output data of each row
  104.     while($row = $result->fetch_assoc()) {
  105.         echo '<div class="post" title="Timestamp: '. $row["clock"] .'">';
  106.         echo '<div class="handle"><div class="tripcode">' . $row["tripcode"]. '</div><div class="user">&lt;<div class="name">'. $row["handle"]. '</div>&gt;</div></div><div class="message">' . $row["message"]. '</div><br>';
  107.         echo '</div>';
  108.     }
  109. } else {
  110.     echo "0 results";
  111. }
  112. $conn->close();
  113. ?>
  114. </body>
  115. </html>
Advertisement
Add Comment
Please, Sign In to add comment