Codice PHP:
if(isset($_POST['submit'])){
session_start();
if(sha1($_POST['codiceverifica']) != $_SESSION['control']){
$error_code= "<span style=\"color:red\">Campo vuoto o non corretto</span>
";
$t++;
}
$categoria=trim($_POST['categoria']);
$nome= trim($_POST['nome']);
$mail= trim($_POST['mail']);
if(empty($categoria)){
$error= "<span style=\"color:red\">Campo vuoto</span>";
$t++;
}
if(empty($nome)){
$error_nome= "<span style=\"color:red\">Campo vuoto</span>";
$t++;
}
if(empty($mail)){
$error_mail= "<span style=\"color:red\">Campo vuoto</span>";
$t++;
}
else{
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $mail)){
$error_mail="<span style=\"color:red\">Mail scritta non correttamente</span>";
}
}
$mittente = "From: Atuttascienza<$mail>\r\n";
$og= "contatti";
$to="jsdd@live.it";
if($t ==0){
mail($to ,$og, $categoria, $mittente);
echo "inviato";
}
else{
echo "<form name=\"FORM3\" method=\"post\" action=\"por.php\">";
echo "<input name=\"categoria\" type=\"text\" value=\"".$categoria."\"> $error
";
echo "<input name=\"nome\" type=\"text\" value=\"".$nome."\"> $error_nome
";
echo "<input name=\"mail\" type=\"text\" value=\"".$mail."\"> $error_mail
";
echo "<img src=\"captcha.php\" width=\"200\" height=\"60\" alt=\"Immagine captcha\">
Inserisci il codice in figura:
<input type=\'text\' name=\"codiceverifica\" size=\"25\"> $error_code</p>";
echo "<input type=\"submit\" name=\"submit\" value=\"submit\"> ";
echo "<input type=\"reset\" name=\"cancel\" value=\"Cancella\">";
echo "</form>";
}
}
else{
echo "<form name=\"FORM2\" method=\"post\" action=\"por.php\">";
echo "<input name=\"categoria\" type=\"text\">
";
echo "<input name=\"nome\" type=\"text\">
";
echo "<input name=\"mail\" type=\"text\">
";
echo "<img src=\"captcha.php\" width=\"200\" height=\"60\" alt=\"Immagine captcha\">
Inserisci il codice in figura:
<input type=\'text\' name=\"codiceverifica\" size=\"25\"></p>";
echo "<input type=\"submit\" name=\"submit\" value=\"submit\"> ";
echo "<input type=\"reset\" name=\"cancel\" value=\"Cancella\">";
echo "</form>";
}
problema
il codice postato fa i controlli sulla stessa pagina...cosi facendo se c'è un campo vuoto o non corretto lo segnala mantenendo i dati che però risultano corretti come si può evincere dal codice sul form con nome form3...il problema è che il tasto reset non cancella i dati che il codice riteneva corretti e ha mantenuto mentre i dati aggiunti manualmente non ancora mandati li cancella...
come ovviare a ciò?