Ver Mensaje Individual
  #7 (permalink)  
Antiguo 15/10/2009, 12:34
Avatar de hieloverde
hieloverde
 
Fecha de Ingreso: julio-2005
Ubicación: México, D.F
Mensajes: 467
Antigüedad: 18 años, 9 meses
Puntos: 5
Respuesta: Problemita con Formulario en PHP

Claro, mira usando tu código he añadido la parte que lee la plantilla externa:

Código HTML:
<?php
require("class.phpmailer.php");
$msg = "";
if ($_POST['action'] == "send") {
    $varname = $_FILES['archivo']['name'];
    $vartemp = $_FILES['archivo']['tmp_name'];
    
    $mail = new PHPMailer();
    $mail->Host = "localhost";
    $mail->From = "nombre";
    $mail->FromName = $_POST['name'];
    $mail->Subject = "Usuarios de prueba";
    $mail->AddAddress('[email protected]');
    if ($varname != "") {
        $mail->AddAttachment($vartemp, $varname);
    }

    /* Parte que procesa la plantilla */
    $abrir_plantilla = fopen("plantilla.html","r"); 
    $plantilla01 = fread($abrir_plantilla,filesize("plantilla.html")); 
    fclose($abrir_plantilla); 

    $plantilla01 = str_replace("{usuario}",$_POST['usuario'],$plantilla01);
    $plantilla01 = str_replace("{pass}",$_POST['pass'],$plantilla01);

    $mail->Body = $plantilla01;
    $mail->IsHTML(true);
    $mail->Send();
    $msg = "Tus datos han sido enviados correctamente, gracias por tu tiempo, ya puedes cerrar la ventana.";
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="200" border="0">
    <tr>
      <td>nombre</td>
      <td><label>
        <input type="text" name="usuario" id="usuario" />
      </label></td>
    </tr>
    <tr>
      <td>contraseña</td>
      <td><label>
        <input type="text" name="pass" id="pass" />
      </label></td>
    </tr>
  </table>
  <p>
    <label>
      <input type="submit" name="button" id="button" value="Enviar" />
    </label>
  </p>
</form>
</body>
</html> 
plantilla.html

Código HTML:
<table border="0" style="color:black;">
    <tr><td colspan="2"><span style="color:red;">Esta es la plantilla en HTML</span></td></tr>
    <tr><td>Usuario: <b>{usuario}</b></td></tr>
    <tr><td>Password: <b>{pass}</b></td></tr>
    <tr><td colspan="2"><i>ALERTA: Contestar al email proporcionado por el cliente, no dar al boton Responder.</i></td></tr>
</table> 
__________________
<? echo("1 <script> dice + que 1000 palabras"); ?> EspacioMéxico