Salve , oggi ho provato a creare una specie di tag board personalizzata, ma vado incontro sempre allo stesso errore, cioè anche quando non scrivo niente e aggiorno la pagina normalmente mi inserisce l'ultimo messaggio scritto da me. ecco il codice:

Codice PHP:
<?php 
$select_commento 
"SELECT username, testo, DATE_FORMAT(tempo, '%d-%m-%Y %h:%i:%s') tempo FROM home";
$result_commento mysql_query($select_commento);
while (
$row_commento mysql_fetch_array($result_commento)){
echo 
"<font color=\"".$coloriPermessi[$row["permessi"]]."\">";
echo 
$row_commento['username']." ";
echo 
"</font>";
echo 
'Scritto il:';
echo 
" ".$row_commento['tempo'];
echo 
'
<font color="green">.................</font>
'
;
echo 
$row_commento['testo'];
echo 
'<hr color="#0066CC">';
}
if (
$_COOKIE["sessioni"]) {
echo 
'<form action="index2.php" method="post">';
echo 
'<input name="invio" type="text" value="Lascia un commento" class="commento" onclick="this.form.invio.value = \'\'"  />';
echo 
'<input name="submit" type="submit" value="invia" class="submit" /></form>';
if(
$_POST['invio']){
$select "SELECT username FROM Registrazione WHERE id='".$_COOKIE['sessioni']."'";
$s_result mysql_query($select) OR DIE (mysql_error());
$row mysql_fetch_array($s_result);
$sql"INSERT INTO home (username, testo, tempo) VALUES ('".$row['username']."','".$_POST['invio']."',now())";
$resultmysql_query($sql) OR DIE (mysql_error());
if (
$result) {
echo 
"<meta http-equiv='refresh' content='0;URL=index2.php'>"
} else {echo 
'<center>commento non inviato</center>';}
}
} else 
{ echo 
'<div class="testo_commento"><font color="red">Per lasciare un commento registrarsi</font></div>';}
?>
secondo me l'errore sta nel if($_POST['invio']) che me lo da sempre presente, però non so come fare diversamente...