<?php
if (isset($_POST['cargar'])) {
header('Content-type: application/msword'); header('Content-Disposition: inline; filename=word.rtf');
?>
<table width="50%" border="4" cellspacing="3" cellpadding="0">
<tr>
<td colspan="2"><h3 align="center" style="background-color:#999999; color:#009933; ">Nombre</h3></td>
</tr>
<tr>
<td><u><?php echo $_POST['nom']; ?></u></td>
<td><span style="font:Verdana, Arial, Helvetica, sans-serif; "><?php echo $_POST['ape']; ?></span></td>
</tr>
</table>
<?php
} // cierra if
?>
<html>
<head>
<title>word desde php</title>
</head>
<body>
<form action="word_formateado.php" method="post">
Nombre: <input type="text" name="nom"> <br>
Apellido: <input type="text" name="ape"> <br>
<input type="submit" name="cargar" value="generar">
</form>
</body>
</html>