Cod: Selectaţi tot
<?php
include("config_shoutbox.php");
if ($_POST['shoutbox_submit']) {
$name = $_POST['shoutbox_name'];
$ip = $_POST['shoutbox_ip'];
$message = $_POST['shoutbox_message'];
$mlen = strlen($message);
$date = date("F jS Y");
if ($name == "") {
echo "<strong>Atentie: Trebuie sa te autentifici.</strong>";
}
else if ($message == "") {
echo "<strong>Atentie: scrie un mesaj.</strong>";
}
else if ($mlen > $max_length) {
echo "<strong>Atentie!: mesajul este prea lung.</strong>";
}
else {
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name) or die("Cannot connect to database");
mysql_query("INSERT INTO shoutbox(name,ip,message,date) VALUES('$name','$ip','$message','$date')");
mysql_close($db);
}
}
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name) or die("Cannot connect to database");
$query = "SELECT * FROM shoutbox ORDER BY id DESC LIMIT $dmessage";
$result = mysql_query($query);
echo "<div class=\"shoutbox\">\n";
echo "<ul>\n";
while($r=mysql_fetch_array($result)) {
//Strips unwanted HTML from nickname
$name = $r['name'];
$name = strip_tags($name);
//Strips unwanted HTML from message
$message = $r['message'];
$message = strip_tags($message);
$date = $r['date'];
$date = ($date);
// Transform text to smileys =)
$message = str_replace("=(","<img src=\"zambete/sad.gif\" alt=\"=(\"/>", $message);
...
$message = ereg_replace(":roll:","<img src=\" zambete/roll.gif\" alt=\":roll:\"/>", $message);
echo "<li title=\"Shouted on $r[date]\" style=\"cursor: pointer\"><strong>$name</strong>: $message</li>\n";
}
echo "</ul>\n";
echo "</div>\n";
mysql_close($db);
?>
Cod: Selectaţi tot
if ($name == "") {
echo "<strong>Atentie: Trebuie sa te autentifici.</strong>";
}
else if ($message == "") {
echo "<strong>Atentie: scrie un mesaj.</strong>";
}