Reputation: 5
Ihave this code that send an email with attachmant and its was working fine, but i did change the message body to have an email with a form look the problem i can't get the data to be showen in mt text box
$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;
}
and the HTML message :
$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"> </td>
<td width="8"> </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> </td>
<td> </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> </td>
<td> </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> </td>
<td> </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> </td>
<td> </td>
<td> </td>
<td nowrap="nowrap"> </td>
</tr>
<tr>
<td height="32">Telf</td>
<td><input name="telf" type="text" id="telf" value="$" /></td>
<td> </td>
<td> </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> </td>
<td> </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> </td>
<td> </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> </td>
<td> </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> </td>
<td> </td>
<td> </td>
<td nowrap="nowrap"> </td>
</tr>
<tr>
<td>Observaciones</td>
<td colspan="5"><textarea name="oserv" id="oserv" cols="58" rows="5"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td nowrap="nowrap"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td nowrap="nowrap"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td nowrap="nowrap"> </td>
</tr>
</table>
</body>
</html>';
i do get the form look email but in the textbox i get so how can i have to show the value in the text box ???
Upvotes: 0
Views: 136
Reputation: 3
You need to reference the variables that contain the text you want to display, and because you're using single quotes instead of double quotes you have to close the quotes on your $message
and use the single dot to join the variable with your text, like this:
<textarea name="oserv" id="oserv" cols="58" rows="5">'.$oserv.'</textarea>
Or:
<input name="date" type="text" id="date" value="'.$date.'" />
For future reference, if you used double quotes, you could reference the variables like this (but you'd need to escape all double quotes in your string with a \
):
$message = "<input name=\"date\" type=\"text\" id=\"date\" value=\"{$date}\" />";
Upvotes: 0
Reputation: 1391
The html form is a php string so you will have to end it to display the php value:
<input name="dpto" type="text" id="dpto" value="'.$depto.'" />
notice the single quote and dot before the variable $depto then the dot and single quote after. when you output the $message variable it will output the value of $depto
Upvotes: 1