ho un problema con questo codice, non riesco a capire dove devo inserire i dati del database MySql, dove posso inserirli quindi?

<?
session_start();
include ('inc/parametri.inc.php');
include ('inc/controllo.php');
include ('inc/open2.php');
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<STYLE>
BODY
{
FONT-SIZE: 10px;
FONT-FAMILY: Verdana;
}
FORM
{
FONT-SIZE: 10px;
COLOR: red;
FONT-FAMILY: Verdana
}
SELECT
{
FONT-SIZE: 10px;
FONT-FAMILY: Tahoma;
TEXT-ALIGN: center
}
A
{
FONT-SIZE: 10px;
COLOR: red;
FONT-FAMILY: Verdana;
TEXT-DECORATION: none
}
A:visited
{
FONT-SIZE: 10px;
COLOR: red;
FONT-FAMILY: Verdana
}
A:hover
{
FONT-SIZE: 10px;
FILTER: glow(color=#000000,strength=1);
COLOR: orange;
FONT-FAMILY: Verdana
}
INPUT
{
FONT-WEIGHT: bolder;
FONT-SIZE: 10px;
COLOR: black;
FONT-FAMILY: Verdana
}
TD
{
FONT-SIZE: 10px;
COLOR: red;
FONT-FAMILY: Verdana;
TEXT-DECORATION: none
}
.titolo
{
FONT-WEIGHT: bolder;
FONT-SIZE: 14px;
COLOR: gold;
FONT-FAMILY: Verdana
}
</STYLE></head>
<body topmargin="0" leftmargin="0" bgcolor=#D8D8D8>
<?
if ($_SESSION['Admin_S'] != 1) {exit();};
include ("inc/controlloesilio.php");

function Tempo($tim) {
return(strftime("%H:%M", strtotime($tim)));
}

$StanzaLog = 0 + $StanzaLog;
if (($op == "Log") && ($StanzaLog != 0)) {

echo "<font color='orange'>Log Stanza $StanzaLog</font>
";

$MySql = " WHERE Stanza = '$StanzaLog' ";
if ($OraDa != "") {
$MySql .= " AND Ora > '$OraDa'";
}
if ($OraAl != "") {
$MySql .= " AND Ora < '$OraAl'";
}

#$MySql = "SELECT * FROM Chat $MySql UNION SELECT * FROM BakChat $MySql ORDER BY ID";
$MySql = "SELECT * FROM Chat $MySql ORDER BY ID";
$Result = mysql_query($MySql);

while ($rs = mysql_fetch_array($Result)) {
echo $rs["ID"]." ".$rs["Tipo"]."&gt; ";
$n = "";
switch ($rs["Tipo"]) {
case "M": #Master scritte nere
$n = "<FONT FACE=Verdana SIZE=1 COLOR=black>".$rs["Testo"]."</FONT>
";
break;
case "C": #Master corporazione scritte blu
$n = "<FONT FACE=Verdana SIZE=1 COLOR='#000050'>".$rs["Testo"]."</FONT>
";
break;
case "H": #Master HTML puro
$n = $rs["Testo"]."
";
break;
case "A": #Azione Pubblica
$n = "<FONT FACE=Verdana SIZE=1 COLOR='#FF1111'>".$rs["Mittente"]." ".$rs["Testo"]."</FONT>
";
break;
case "X": #Sistema
$n = "<FONT FACE=Verdana SIZE=1 COLOR=red>".$rs["Testo"]."</FONT>
";
break;
case "Y": #Azioni speciali: dadi ecc.
$n = "<FONT FACE=Verdana SIZE=1 COLOR=purple>".$rs["Testo"]."</FONT>
";
break;
case "S": #Sussurro
$n = "<FONT FACE=Verdana SIZE=1 COLOR=gray>".$rs["Mittente"]." a ".$rs["Destinatario"].": ".$rs["Testo"]."</font>
";
break;
case "P": #Messaggio Pubblico
if (strtolower($rs["Sesso"]) == "m") {
$ColoreFont = "#0000FF";
} elseif (strtolower($rs["Sesso"]) == "f") {
$ColoreFont = "#FF5555";
} else {$ColoreFont = "#606060";}
$n = "<FONT FACE=Verdana SIZE=2 COLOR=#606060>";
$n .= "".Tempo($rs["Ora"])." ";
$n .= "[img]img/testamini".strtolower($rs["Sesso"]).".gif[/img]";
$n .= " <font color=#000000>".htmlspecialchars($rs["Mittente"])."";
#$n .= "<a href='scheda.php?pg=".urlencode($rs["Mittente"])."' target=_new>";
#$n .= "[img]img/stemmi/".$rs["ImgGilda"]."[/img]";
#$n .= "</a>";
$n .= "".$rs["Testo"]."</FONT></FONT>
";
break;
}
echo $n;
}
echo "<hr>";
$rs -> close;
}
?>
<form action="pass.php" method="Post">
<input type=hidden name="op" value="Log">
<font color=red>Log Chat # <input type=text name="StanzaLog" size=4 Value="<?= $StanzaLog ?>"> dalle <input type=text name="OraDa" value="<?= $OraDa ?>"> alle <input type=text name="OraAl" value="<?= $OraAl ?>">
<input type=submit value="Log Chat">
</form>
</font>
torna al gioco
</body>
</html>


ringrazio anticipatamente della riposta