Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html><head>
- <style type="text/css">
- body
- {
- color: #3650A4;
- font-size: 14px;
- background-color: #356D24;
- }
- #shouts {
- height: 130px;
- overflow: auto;
- }
- #shout1 {
- background-color: #73B65E;
- }
- #shout2 {
- background-color: #7CBB68;
- }
- #shout-container{
- width: 100%;
- height: 100%;
- background-color: #67B050;
- }
- </style>
- </head><body>
- <?php
- $host = "*****";
- $user = "*****";
- $pass = "******";
- $db = "*******";
- $error = 0;
- mysql_connect($host, $user, $pass) OR die ("Could not connect to the server.");
- mysql_select_db($db) OR die("Could not connect to the database.");
- if ($_POST['submit'] && $_POST['name'] && $_POST['message']) {
- $name = $_POST['name'];
- $message = $_POST['message'];
- if (strlen($message) > 100) {
- echo "<div id=\"shout1\">your message is longer than 100 chars<br /><a href=\"shoutbox.php\">Back to messages</a></div>";
- $error = 1;
- }
- if (strlen($name) > 15) {
- echo "<div id=\"shout1\">your name is longer than 15 chars<br /><a href=\"shoutbox.php\">Back to messages</a></div>";
- $error = 1;
- }
- $message = htmlspecialchars($message);
- $message = nl2br($message);
- $message = mysql_real_escape_string($message);
- $name = htmlspecialchars($name);
- $name = mysql_real_escape_string($name);
- if ($error != 1) {
- mysql_query("INSERT INTO shoutbox (name, message) VALUES ('$name', '$message')");
- }
- }
- if ($error != 1) {
- ?>
- <div id="shout-container">
- <div id="shouts">
- <?php
- $result = mysql_query("SELECT * FROM shoutbox ORDER BY id DESC LIMIT 0,10");
- $color = 1;
- while ($row = mysql_fetch_array($result)) {
- ?>
- <div id="shout<?php echo $color; ?>">
- <b><?php echo $row['name']; ?></b><br />
- <?php echo $row['message']; ?></div>
- <?php
- $color++;
- if ($color == 3) {
- $color = 1;
- }
- }
- ?>
- </div>
- <div align="center">
- <form action="shoutbox.php" method="post">
- Name:<br /><input type="text" maxlength="15" name="name"><br />
- Message:<br /><textarea name="message" cols="10" rows="3"></textarea><br />
- <input type="submit" name="submit" value="Submit"> <input type="reset">
- </form>
- </div>
- </div>
- <?php
- }
- ?></body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement