El código completo (la página la llamaremos, por ejemplo, bienvenida.php):
Código: Seleccionar todo
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$nombre = htmlspecialchars($_POST['nombre']);
$email = htmlspecialchars($_POST['email']);
echo "¡Hola, " . $nombre . "!<br>";
echo "Tu dirección de correo electrónico es: " . $email;
}
?>
<!DOCTYPE html>
<html>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
Nombre: <input type="text" name="nombre">
<br>
Email: <input type="text" name="email">
<br>
<input type="submit">
</form>
</body>
</html>