Ecco il mio assurdo problema: ho una pagina, textarea e submit, scrivo del testo, invio, viene stampato il testo, ricomincio questo ciclo, stessa cosa, due form di testo, poi quando ricarico la pagina, tutto scompare, nel senso, tutti i testi inseriti, impilati come mattoni non vengono ripresi. Che ciclo dovrei fare?
Cioè, che dovrei inserire nel codice php? Ciclo if, while? Non so
Dai posto qualche script:
Codice PHP:
if (isset($_POST['comment'])) {
$text = $_POST['comment'];
if ($text!='') {
$con = mysql_connect('localhost','root','')
or die ('Errore di connessione');
mysql_select_db('noteit')
or die ('Dati non presenti');
$date = (date('d-m-Y'));
$time = (date('G:i:s'));
$tic = 0;
$query1 = mysql_query("SELECT * FROM utenti WHERE EMAIL='".$email."' AND CODE='".$code."'");
$insert = mysql_query("INSERT INTO home VALUES ('','".$nom."','".$cog."','".$date."','".$time."','".$text."','".$tic."')");
$query2 = mysql_query("SELECT * FROM home");
$numrow = mysql_num_rows($query2);
$tic = 0;
if ($numrow!=0) {
while ($row = mysql_fetch_assoc($query2)) {
$text = $row['TESTO'];
$tab = "<div id='box7' class='centro2 testo c1' align='justify'>
<div>
[b]$nom $cog[/b]
</div>
<div style='border: 1 solid #f0f0f0'>
$text
<div style='float: right'>
<form action=\"".htmlentities($_SERVER['PHP_SELF'])."\" method='POST'>
<span id='ntic'>$tic</span>
<input
type='submit'
name='tic'
value=''
id='tic'
class='btn0 testo c1 cb2'
onmouseout=\"this.className = 'btn0 testo c1 cb2';\"
onmouseover=\"this.className = 'btn1 testo c2 cb1';\"/>
</form>
</div>
</div>
</div>";
echo $tab;
$text = NULL;
}
}
} else {
$text = NULL;
}
}