Grazie, ma cercando unpò con google ho visto che il php deriva dal c, perciò ho provato a scrivere il codice basandomisu di esso ed ha funzionato, in pi ho aggiunto una funziona trovata per caso.
Codice HTML:
<div id="ins"><form action="ins.php" method=post>
<p>Nome:</p>
<input type="text" name="nome" maxlength="30"><br />
<br /><p>(obbligatoria)(non visualizzata)Mail:</p>
<input type="text" name="mail" maxlength="100"><br />
<br /><P>Commento:</p>
<textarea name="commento" cols=40 rows=6 maxlength="300"></textarea>
<br /><input type="submit" value="invia" name="invia"></form>
</div>
<br /><br />
</div>
Codice PHP:
<?php
$dateform = date("d/m/Y");
$timeform = date("H:i");
$testo=htmlentities($_POST['commento']);
$testo= nl2br($testo);
$nome=htmlentities($_POST['nome']);
$database='database/contatti.txt';
$datamail='database/mail.txt';
$mail=$_POST['mail'];
If (empty($nome))
{
ob_start();
echo "Inserire il nome obbligatoriamente.";
header( "refresh:2;url=guestbook.php" );
ob_end_flush();
}
If (empty($mail))
{
ob_start();
echo "Inserire e-mail obbligatoriamente.";
header( "refresh:2;url=guestbook.php" );
ob_end_flush();
}
If (empty($testo))
{
ob_start();
echo "Inserire testo obbligatoriamente.";
header( "refresh:2;url=guestbook.php" );
ob_end_flush();
}
If (!empty($mail))
If (!empty($testo))
If (!empty($nome))
{
$open = fopen($database,'a');
fwrite( $open, "\n<hr id='bordi'><p>".$dateform." ".$timeform."</p><br /><h3>".$nome." scrive:<h3> <hr /><br /> <p>".$testo."</p><br /><hr id='bordi'>" );
fclose($open);
$open = fopen($datamail,'a');
fwrite( $open, "\n\n".$nome." - ".$mail."\n\n" );
ob_start();
echo "Messaggio inserito perfettamente.";
header( "refresh:2;url=guestbook.php" );
ob_end_flush();
}
?>
Ora l'unica cosa che mi serve è come fare il controllo che ci sia la @ nella mail.