如何获取我的HTML电子邮件表单的价值?

时间:2014-03-12 23:08:45

标签: php html email

我有这个代码,发送一个带有attachmant的电子邮件,它的工作正常,但我确实更改了邮件正文,让一封带有表单的电子邮件看起来问题我无法在mt文本中显示数据方框

  $rowSQL = mysql_query( "SELECT MAX( ID ) AS max FROM `consulta` ;" );
$row = mysql_fetch_array( $rowSQL );
$largestNumber = $row['max'];
//echo  $largestNumber;

$allData = mysql_query("SELECT * FROM `consulta`  WHERE ID = $largestNumber;" );


while($rows = mysql_fetch_array($allData)) {
    $email =$rows['EMAIL'];
    $depto = $rows['N_DPTO'];
    // NEW
    $nombre = $rows['NOMBRE1'];
    $apeellido = $rows['APELLIDO1'];
    $dni = $rows['DNI'];
    $phone = $rows['TELF'];
    $direccion = $rows['DIRECCION'];
    $date = $rows['DATE'];
    $refrencia = $rows['REFERENCIA'];
    $nestac = $rows['N_ESTACIONAMIENTO'];
    $deposito = $rows['N_DEPOSITO'];
    $dptoprice = $rows['P_DPTO'];
    $esprice = $rows['P_ESTACIONAMIENTO'];
    $depoprice = $rows['P_DEPOSITO'];
    $separacion = $rows['SEPARACION'];
    $cuota = $rows['CUOTA'];
    $montofin = $rows['MONTO_FIN'];
    $entidadfin = $rows['ENTIDAD_FIN'];
    $observacion = $rows['OBSERVACIONES'];
    $ncotizacion = $rows['N_COTIZACION'];
    $user = $rows['USER_ID'];
    // END NEW

    echo $email;
    echo $depto;
}

和HTML消息:

$message = '<html>
        <body>
            <table width="639" border="0">
      <tr>
        <td height="38" colspan="6"><h2>Gracias por tu visita
            <label for="dpto"></label>
        </h2></td>
      </tr>
      <tr>
        <td width="148">Depto</td>
        <td width="144"><input name="dpto" type="text" id="dpto" value="<?php echo  $depto;?>" /></td>
        <td width="3">&nbsp;</td>
        <td width="8">&nbsp;</td>
        <td width="136">Vendedor</td>
        <td width="174" nowrap="nowrap"><label for="cotizacion">
          <input name="user" type="text" id="user" value="" />
        </label></td>
      </tr>
      <tr>
        <td>Fecha</td>
        <td><label for="esta">
          <input name="date" type="text" id="date" value="$" />
        </label></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>Documento</td>
        <td nowrap="nowrap"><label for="deposito">
          <input name="cotizacion" type="text" id="cotizacion" value="$" />
        </label></td>
      </tr>
      <tr>
        <td>Estacionamiento</td>
        <td><input name="esta" type="text" id="esta" value="$" /></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>Deposito</td>
        <td nowrap="nowrap"><input name="deposito" type="text" id="deposito" value="$" /></td>
      </tr>
      <tr>
        <td height="64" colspan="6" valign="middle"><h2>Datos Del Cliente</h2></td>
      </tr>
      <tr>
        <td>Nombre</td>
        <td><input name="name" type="text" id="name2" value="$" /></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>Apellido</td>
        <td nowrap="nowrap"><input name="family" type="text" id="family" value="$" /></td>
      </tr>
      <tr>
        <td>DNI</td>
        <td><input name="dni" type="text" id="dni" value="$" /></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td nowrap="nowrap">&nbsp;</td>
      </tr>
      <tr>
        <td height="32">Telf</td>
        <td><input name="telf" type="text" id="telf" value="$" /></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>Email</td>
        <td nowrap="nowrap"><input name="email" type="text" id="email" value="$" /></td>
      </tr>
      <tr>
        <td>Direccion</td>
        <td colspan="5"><input name="address" type="text" id="address" value="$" size="74" /></td>
      </tr>
      <tr>
        <td>Como se Entero</td>
        <td colspan="5"><input name="como" type="text" id="como" value="$" size="74" /></td>
      </tr>
      <tr>
        <td height="56" colspan="6"><h2>Datos Financieros</h2></td>
      </tr>
      <tr>
        <td>Precio Dpto S/.</td>
        <td><input name="pDpto" type="text" id="pDpto" value="$" /></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>Precio Estacio S/.</td>
        <td nowrap="nowrap"><input name="pEsta" type="text" id="pEsta" value="$" /></td>
      </tr>
      <tr>
        <td>Precio Deposito S/.</td>
        <td><input name="pDeposito" type="text" id="pDeposito" value="$" /></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>Separacion S/.</td>
        <td nowrap="nowrap"><input name="separacion" type="text" id="separacion" value="$" /></td>
      </tr>
      <tr>
        <td>Cuota S/.</td>
        <td><input name="couta" type="text" id="couta" value="$" /></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>Monto Financia</td>
        <td nowrap="nowrap"><input name="monto" type="text" id="monto" value="$" /></td>
      </tr>
      <tr>
        <td>Entidad Financia</td>
        <td><input name="entidad" type="text" id="entidad" value="$" /></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td nowrap="nowrap">&nbsp;</td>
      </tr>
      <tr>
        <td>Observaciones</td>
        <td colspan="5"><textarea name="oserv" id="oserv" cols="58" rows="5"></textarea></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td nowrap="nowrap">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td nowrap="nowrap">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td nowrap="nowrap">&nbsp;</td>
      </tr>
    </table>
</body>
</html>';

我确实得到表格看电子邮件,但在文本框中我得到了如何我必须在文本框中显示值???

2 个答案:

答案 0 :(得分:1)

html表单是一个php字符串,所以你必须结束它才能显示php值:

<input name="dpto" type="text" id="dpto" value="'.$depto.'" />

注意变量$ depto之前的单引号和点,然后是点和单引号。当你输出$ message变量时,它将输出$ depto

的值

答案 1 :(得分:0)

您需要引用包含要显示的文本的变量,并且因为您使用单引号而不是双引号,您必须关闭$message上的引号并使用单点加入带有文字的变量,如下所示:

<textarea name="oserv" id="oserv" cols="58" rows="5">'.$oserv.'</textarea>

或者:

<input name="date" type="text" id="date" value="'.$date.'" />

为了将来参考,如果您使用双引号,则可以引用这样的变量(但您需要使用\转义字符串中的所有双引号):

$message = "<input name=\"date\" type=\"text\" id=\"date\" value=\"{$date}\" />";