La serie di codici è molta lunga , ma non capisco il motivo ma non mi funziona.
File Chat.php
Codice PHP:
<html>
<head>
<title>Documento senza titolo</title>
</head>
<body>
<iframe name="Chatview" src="Chatview.php" frameborder="0" framespacing="0" width="100%" height="95%"></iframe>
<iframe name="Chatengine" src="Chatengine.php" frameborder="0" framespacing="0" width="100%" height="5%" scrolling="no"></iframe>
</body>
</html>
File Chatengine.php
Codice PHP:
<html>
<head>
<title>Documento senza titolo</title>
</head>
<body>
<form name="INform" method="post" action=”Chatdaemon.php” onSubmit="javascript:location.reload();">
<input type="text" name="message" size="45">
<input type="submit" value="Invia" name="inviato" onclick="javascript:document.INform.message.focus();">
</form>
</body>
</html>
File Chatview.php
Codice PHP:
<html>
<head>
<meta http-equiv="refresh" content="10,Chatview.php" />
<title>Documento senza titolo</title>
</head>
<body>
<?php
include("config.inc.php");
$db = mysql_connect($db_host, $db_user, $db_password);
if ($db == FALSE){
die ("Errore nella connessione. Verificare i parametri nel file config.inc.php");
}
mysql_select_db($db_name, $db) or die ("Errore nella selezione del database. Verificare i parametri nel file config.inc.php");
$actualtime=time();
$refresh=mysql_query("DELETE FROM chat WHERE timein+600<'$actualtime'",$db);
$exec_reading=mysql_query("SELECT * FROM chat WHERE locazione='$locazione_attuale' ORDER BY timein DESC",$db)
$numrows=mysql_num_rows($exec_reading);
if($numrows!=0)
{
for($x=0;$x<$numrows;$x++)
{
$resrow=mysql_fetch_row($exec_reading);
$nomeChat=$resrow[0];
$messChat=stripslashes($resrow[1]);
echo $messChat;
}
}
?>
</body>
</html>
File Chatdaemon.php
Codice PHP:
<html>
<head>
<title>Documento senza titolo</title>
</head>
<body>
<?php
$chat_text=$_POST['message'];
include("config.inc.php");
$db = mysql_connect($db_host, $db_user, $db_password);
if ($db == FALSE){
die ("Errore nella connessione. Verificare i parametri nel file config.inc.php");
}
mysql_select_db($db_name, $db) or die ("Errore nella selezione del database. Verificare i parametri nel file config.inc.php");
$time=mysql_fetch_row(mysql_query("SELECT curtime()",$db));
$tmptime=time();
$chat_text=addslashes($chat_text);
$chat_text[0]=strtolower($chat_text[0]);
$chat_text="<p align=justify>" . $time[0]. " - " . "[b]<font face=arial size=2>$chatter[/b]" . ": " . htmlspecialchars($chat_text) . "</font></p>";
$log_chat=mysql_query("INSERT INTO chat(ID,message,locazione,timein) VALUES ('$chatter','$chat_text','$locazione','$tmptime')",$db);
header("Location:Chatview.php",true);
?>
</body>
</html>
Se ci date un occhio mi fate un grosso piacere.