Sigo sin entender, a ver si ete ejemplo (muy básico) te aclara el panorama
Archivo index_conectar.php
Código PHP:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>titulo</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
$error = "";
$script = "";
if(isset($_POST['procesar'])){ if(($_POST['nombre'] != "") && ($_POST['apellido'] != "")){
echo "gracias " . $_POST['nombre'] . " " . $_POST['apellido'];
$script = "<script>document.getElementById('ingresa_datos').style.display = 'none';</script>";
}else{
$error = "<p>Debe completar ambos campos</p>";
}
}
?>
<form name="ingresa_datos" method="post" action="index_conectar.php" id="ingresa_datos">
nombre: <input type="text" name="nombre" value="
<?php if(isset($_POST['nombre'])){echo $_POST['nombre'];} ?>" /><br />
nombre: <input type="text" name="apellido" value="
<?php if(isset($_POST['apellido'])){echo $_POST['apellido'];} ?>" /><br />
<input type="submit" name="procesar" value="procesar"/>
</form>
<?php
echo "$error\n";
echo "$script\n";
?>
</body>
</html>
Saludos