ZoomCities IT Community Webmaster Forum

Full Version: shoutout box script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Shoutbox
Code:
<style type="text/css">
<!--
#contentbox {
background: #E5E5E5;
padding: 5px;
width: 195px;
height: 200px;
overflow: auto; }
ul#shoutboxmessage {
margin: 0;
padding: 0;
list-style-type: none;
color: #000000;
font: normal 10px verdana,tahoma,arial; }
-->
</style>
<?php
require_once("config.php");
$name = $_POST['name'];
$message = $_POST['message'];
$ip = $_POST['ip'];
$mlen = strlen($message);
$maxlength = 150;
$date = date("M jS Y");
if ($_POST['submit']) {
if ($name == "") {
echo "<strong>Error: Please enter your nickname.</strong>";
}
else if ($message == "") {
echo "<strong>Error: No message to be sent.</strong>";
}
else if ($mlen > $maxlength) {
echo "<strong>Error: Message too long.</strong>";
}
else {
$db = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname) or die(mysql_error());
mysql_query("INSERT INTO shoutbox(name,message,date,ip) VALUES('$name','$message','$date','$ip')");
}
}
$db = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname) or die(mysql_error());
$query = "SELECT * FROM shoutbox ORDER BY id DESC LIMIT 20";
$result = mysql_query($query);
echo "<div id=\"contentbox\">\n";
echo "<ul id=\"shoutboxmessage\">\n";
while($r = mysql_fetch_array($result)) {
$name = $r['name'];
$name = strip_tags($name);
$message = $r['message'];
$message = strip_tags($message);
echo "<li><strong>>$name</strong>: $message</li>\n";
}
echo "</ul>\n";
echo "</div>\n";
mysql_close($db);
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<strong>Nickname:</strong><br/>
<input type="text" name="name" maxlength="20"><<br/>
<strong>Message:</strong><br/>
<textarea name="message"></textarea><br/>
<input type="submit" name="submit" value="Shout It!">
<input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>">
</form>
</div>
?>
Save this as shoutbox.php
Where did you get this script, wawa? The reason I'm asking is because it doesn't seem like it's a complete script.

Code:
require_once("config.php");

Where's the config.php file? Also, could you explain a bit more about what the script does? I admire your efforts in finding these scripts for us, wawa, but I don't think the admin will be happy if you are only posting a copy/pasted script just to get another post.
please complete the script. give us the config code also
I think the database informations, as well as database variables is in config.php.. But we also need to know the proper format of the code included in config.php so please, can you also post the config.php?
Please post the config.php....
Andrei Wrote:Please post the config.php....
If you want to live, don't use this script. It's open to SQL Injection attacks and it's inputing it directly into the db which is a big no-no. If you're curious though, it looks like the config file just holds $dbname,$dbhost,$dbuser, and $dbpass variables.
Reference URL's