Código PHP:
//Logica del oculto de: oculto
if(array_key_exists("oculto", $_POST)) {
if (comprovar_formulario()) {
procesar_formulario();
} else{
mostrar_formulario();
}
} else {
mostrar_formulario();
}
//Hacer algo cuando se envia el formulario
function procesar_formulario() {
print "Hola" . $_POST["mi_nombre"];
}
//Mostrar el formulario
function mostrar_formulario() {
print <<<_HTML_
<form method="post" action="$_SERVER[PHP_SELF]">
Tu nombre: <input type="text" name="mi_nombre">
<br />
<input type="submit" value="Imprime">
<input type="hidden" name="oculto" value="1">
</form>
_HTML_;
}
//Comprovar los datos del formulario
function comrpobar_formulario() {
if (strlen($_POST['mi_nombre') < 3) {
return false;
} else {
return true;
}
}