Advertisement
Guest User

Untitled

a guest
May 3rd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. <html><head>
  2. <style type="text/css">
  3.  
  4. body
  5. {
  6. color: #3650A4;
  7. font-size: 14px;
  8. background-color: #356D24;
  9. }
  10.  
  11. #shouts {
  12. height: 130px;
  13. overflow: auto;
  14. }
  15.  
  16. #shout1 {
  17. background-color: #73B65E;
  18. }
  19.  
  20. #shout2 {
  21. background-color: #7CBB68;
  22. }
  23.  
  24. #shout-container{
  25. width: 100%;
  26. height: 100%;
  27. background-color: #67B050;
  28. }
  29. </style>
  30. </head><body>
  31. <?php
  32. $host = "*****";
  33. $user = "*****";
  34. $pass = "******";
  35. $db = "*******";
  36. $error = 0;
  37. mysql_connect($host, $user, $pass) OR die ("Could not connect to the server.");
  38. mysql_select_db($db) OR die("Could not connect to the database.");
  39. if ($_POST['submit'] && $_POST['name'] && $_POST['message']) {
  40. $name = $_POST['name'];
  41. $message = $_POST['message'];
  42. if (strlen($message) > 100) {
  43. echo "<div id=\"shout1\">your message is longer than 100 chars<br /><a href=\"shoutbox.php\">Back to messages</a></div>";
  44. $error = 1;
  45. }
  46. if (strlen($name) > 15) {
  47. echo "<div id=\"shout1\">your name is longer than 15 chars<br /><a href=\"shoutbox.php\">Back to messages</a></div>";
  48. $error = 1;
  49. }
  50. $message = htmlspecialchars($message);
  51. $message = nl2br($message);
  52. $message = mysql_real_escape_string($message);
  53. $name = htmlspecialchars($name);
  54. $name = mysql_real_escape_string($name);
  55. if ($error != 1) {
  56. mysql_query("INSERT INTO shoutbox (name, message) VALUES ('$name', '$message')");
  57. }
  58. }
  59. if ($error != 1) {
  60. ?>
  61. <div id="shout-container">
  62. <div id="shouts">
  63. <?php
  64. $result = mysql_query("SELECT * FROM shoutbox ORDER BY id DESC LIMIT 0,10");
  65. $color = 1;
  66. while ($row = mysql_fetch_array($result)) {
  67. ?>
  68. <div id="shout<?php echo $color; ?>">
  69. <b><?php echo $row['name']; ?></b><br />
  70. <?php echo $row['message']; ?></div>
  71. <?php
  72. $color++;
  73. if ($color == 3) {
  74. $color = 1;
  75. }
  76. }
  77. ?>
  78. </div>
  79. <div align="center">
  80. <form action="shoutbox.php" method="post">
  81. Name:<br /><input type="text" maxlength="15" name="name"><br />
  82. Message:<br /><textarea name="message" cols="10" rows="3"></textarea><br />
  83. <input type="submit" name="submit" value="Submit"> <input type="reset">
  84. </form>
  85. </div>
  86. </div>
  87. <?php
  88. }
  89. ?></body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement