Un esempio....
Uso PHP 4.0.6. Se usi una versione + recente devi mettere $_POST al posto di $HTTP_POST_VARS.codice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <? //----------- Inizializzo il nome e il suo commento $nome = ''; $commentNome = 'Nome'; //----------- Inizializzo il cognome e il suo commento $cognome = ''; $commentCognome = 'Cognome'; //------------ Testo se il pulsante invio è stato cliccato $invio = ""; if (isset($HTTP_POST_VARS['invio'])) { $invio = $HTTP_POST_VARS['invio']; } // if (isset($HTTP_POST_VARS['invio'])) if ($invio == "sottomettere") { //----------- Il nome if (isset($HTTP_POST_VARS['nome'])) { if (empty($HTTP_POST_VARS['nome'])) { //------------ Il nome è vuoto, metto il commento in rosso $commentNome = "<span style='color:red'>$commentNome</span>"; } else { $nome = $HTTP_POST_VARS['nome']; } // if (empty($HTTP_POST_VARS['nome'])) } // if (isset($HTTP_POST_VARS['nome'])) //----------- Il cognome if (isset($HTTP_POST_VARS['cognome'])) { if (empty($HTTP_POST_VARS['cognome'])) { //------------ Il cognome è vuoto, metto il commento in rosso $commentCognome = "<span style='color:red'>$commentCognome</span>"; } else { $cognome = $HTTP_POST_VARS['cognome']; } // if (empty($HTTP_POST_VARS['conome'])) } // if (isset($HTTP_POST_VARS['conome'])) } // if ($invio == "sottomettere") ?> <body> <form action="test2027.php" method="post"> <? print $commentNome ?><input type="text" name="nome" value="<? print $nome ?>"> <? print $commentCognome ?><input type="text" name="cognome" value="<? print $cognome ?>"> <input type="submit" name="invio" value="sottomettere"> </form> </body> </html>

Rispondi quotando