salut, inspirate de aici:
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";
echo "<b><p align=center>Daca vreti sa scrieti sau sa anuntati ceva in aceasta rubrica, trebuie sa aveti cont si sa va autentificati!</b>";
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];
// Transform text to smileys =)
$message = str_replace("=(","<img src=\"imagini/zambete/sad.gif\" alt=\"=(\"/>", $message);
$message = str_replace(":(","<img src=\"imagini/zambete/sad.gif\" alt=\":(\"/>", $message);
$message = str_replace(";(","<img src=\"imagini/zambete/cry.gif\" alt=\";(\"/>", $message);
$message = str_replace(":@","<img src=\"imagini/zambete/mad.gif\" alt=\":@\"/>", $message);
$message = ereg_replace(":)","<img src=\"imagini/zambete/smile.gif\" alt=\":)\"/>", $message);
$message = ereg_replace("=)","<img src=\"imagini/zambete/smile.gif\" alt=\"=)\"/>", $message);
$message = ereg_replace(":D","<img src=\"imagini/zambete/laugh.gif\" alt=\":D\"/>", $message);
$message = ereg_replace(":d","<img src=\"imagini/zambete/laugh.gif\" alt=\":d\"/>", $message);
$message = ereg_replace(":p","<img src=\"imagini/zambete/tongue.gif\" alt=\":p\"/>", $message);
$message = ereg_replace(":P","<img src=\"imagini/zambete/tongue.gif\" alt=\":P\"/>", $message);
$message = ereg_replace(":O","<img src=\"imagini/zambete/shocked.gif\" alt=\":O\"/>", $message);
$message = ereg_replace(":o","<img src=\"imagini/zambete/shocked.gif\" alt=\":o\"/>", $message);
$message = ereg_replace(";)","<img src=\"imagini/zambete/wink.gif\" alt=\";)\"/>", $message);
$message = ereg_replace(":S","<img src=\"imagini/zambete/sick.gif\" alt=\":S\"/>", $message);
$message = ereg_replace(":s","<img src=\"imagini/zambete/sick.gif\" alt=\":s\"/>", $message);
$message = ereg_replace(":roll:","<img src=\" imagini/zambete/roll.gif\" alt=\":roll:\"/>", $message);
echo "<li title=\"Data afisarii: $r[date]\" style=\"cursor: pointer\"><strong>$name</strong>: $message </li> <p align=right>$date</p>\n";
}
echo "</ul>\n";
echo "</div>\n";
mysql_close($db);
?>