Ok....Ecco il codice:
Codice PHP:
<strong></strong><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento senza titolo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
include("configura.php");
session_start();
$attivo = $_SESSION['attivo'];
$username = $_SESSION['username'];
if ($attivo == "")
{
header("location: login.php");
}
else
{
if ($attivo == TRUE)
{
$myconn = mysql_connect($db_host, $db_username, $db_password) or die("Errore...");
mysql_select_db($db_name, $myconn) or die("Errore...");
$query = "SELECT * FROM chat ORDER BY id DESC";
$result = mysql_query($query, $myconn) or die("Errore selezione messaggio...");
$numrows = mysql_num_rows($result);
if ($numrows==0){
print"Nessun messaggio!";
}
else
{
for($x=0; $x<$numrows; $x++){
$resrow = mysql_fetch_row($result);
$messaggio = $resrow[1];
$usernamee = $resrow[2];
print " <b> $usernamee: </b>" . $messaggio . "<br>";
if ($numrows >= $numero_messaggi)
{
mysql_query("DELETE FROM chat WHERE id >= 1");
}
else
{
}
}
}
}
else
{
header("location:login.php");
}
}
?>
<script>
window.setTimeout("window.location.reload()",05000);
</script>