Jump to content

Ayuda con formulario


Recommended Posts

Hola amigos, nesecito hacer un formulario de cotizacion asi como este http://www.opticasweber.cl/cotiza.php

 

ya tengo el formulario echo pero no se como meter todos esos datos en el php que envia el formulario, es la primera vez que hago un formulario con tantos datos. yo trabajo con este script:

 

<?php

 

$nombre = $_POST['nombre'];

$direccion = $_POST['direccion'];

$email = $_POST['email'];

$telefono = $_POST['telefono'];

 

$header = 'From: ' . $email . " \r\n";

$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";

$header .= "Mime-Version: 1.0 \r\n";

$header .= "Content-Type: text/plain";

 

$mensaje = "Este mensaje fue enviado por " . $nombre ." \r\n";

$mensaje .= "Su e-mail es: " . $email . " \r\n";

$mensaje .= "Su direccion es: " . $direccion . " \r\n";

$mensaje .= "Su telefono es: " . $telefono . " \r\n";

$mensaje .= "Enviado el " . date('d/m/Y', time());

 

$para = '[email protected]';

$asunto = 'Cotizacion desde ';

 

mail($para, $asunto, utf8_decode($mensaje), $header);

echo "Gracias. su mensaje a sido enviado con exito!"

?>

 

Lo que quiero saber es si es necesario pasar todos los datos $_POST['DATO1'] a --> $dato1

o si existe la forma de mandar el mail con la misma extructura del formulario pero con los datos que el cliente eligio?

 

Ojala alguien me pueda ayudar!!! GRACIAS

 

Link to comment
Share on other sites

Holas.

 

 

Por lo que te entendi, el pasar los datos de post a variables eso se puede evitar escribiendo altiro la variable que viene en post. me explico..

 

$header = 'From: ' . $email . " \r\n";

 

Por

 

$header = 'From: ' . $_POST['email'] . " \r\n";

 

Eso dara lo mismo. aHora dejar exactamente igual como esta le formulario tambien se puede o dejar algo similar a travez de html.

es decir, es vez de escribir el correo con texto plano, lo haces con html y ahi podras crear tablas y hacer un sin fin de cosas.

 

Solo tienes que cambiar el encabezado.

 

"Content-Type: text/plain";

 

Por:

'Content-type: text/html; charset=iso-8859-1' . "\r\n";

 

 

 

Espero que te sirva esto..

:)

 

 

Link to comment
Share on other sites

Gracias! eso era lo que buscaba, pero ahora tengo otra duda. Como le pongo los datos dentro de mensaje??? ejemplo:

 

$header = 'From: ' . $email . " \r\n";
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\n"

$cuerpo_mail="

<html>
<head>
<title>Documento sin título</title>
</head>

<body>
MENSAJE ENVIADO POR: $_POST['nombre'] | SU EMAIL ES: $_POST['email'] <br />
SU DIRECCION ES: $_POST['direccion'] | Y SU TELEFONO ES $_POST['telefono']
......

 

 

Asi esta bien???, o hay que poner asi: <? $_POST['nombre'] ?>

 

Gracias!

Edited by panchompc
Link to comment
Share on other sites

Derias hacerlo asi.

 

$cuerpo_mail = '
<html>
<head>
<title>Documento sin título</title>
</head>

<body>
MENSAJE ENVIADO POR: '.$_POST['nombre'].' | SU EMAIL ES: '.$_POST['email'].' <br /> 
SU DIRECCION ES: '.$_POST['direccion'].' | Y SU TELEFONO ES '.$_POST['telefono'].';

 

Fijate en los '. $variable .' asi concatenaras las variables al texto que estas ingresando.

 

 

Saludos.

 

Link to comment
Share on other sites

Gracias The.manolox. pero cuando lo subo al servidor y lo ejecuto me sale:

 

Parse error: syntax error, unexpected T_VARIABLE in /home/vhosts/**SITIO**/cotiza.php on line 13

 

la linea 13 es :

 

$cuerpomail=" /// aqui es donde empieso a poner el codigo en html

 

Por que puede ser esto??

 

Link to comment
Share on other sites

Hola. Ahy esta el php

 

 

 

<?php

 

$nombre = $_POST['nombre'];

$direccion = $_POST['direccion'];

$email = $_POST['email'];

$telefono = $_POST['telefono'];

 

$header = 'From: ' . $email . " \r\n";

$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";

$header .= "Mime-Version: 1.0 \r\n";

$header .= "Content-type: text/html; charset=iso-8859-1\n"

 

$cuerpomail = "

<html>

<head>

<title>Documento sin título</title>

</head>

 

<body>

<P>MENSAJE ENVIADO POR: '.$_POST['nombre'].' | SU EMAIL ES: '.$_POST['email'].' <br />

SU DIRECCION ES: '.$_POST['direccion'].' | Y SU TELEFONO ES: '.$_POST['telefono'].'</P>

 

<P>LENTE LEJOS <BR />

OD ESF: '.$_POST['lodesf'].' | CIL: '.$_POST['lodcil'].' | EJE:'.$_POST['lodeje'].' | PRISMA: '.$_POST['lodpris'].' <BR />

OI ESF: '.$_POST['loiesf'].' | CIL :'.$_POST['loicil'].' | EJE:'.$_POST['loieje'].' | PRISMA: '.$_POST['loipris'].' <BR />

DP: '.$_POST['lejosdp'].'

 

//** NO E CONTINUADO PORQUE SON COMO 30 DATOS MAS DESDE EL FORMULARIO **\\

 

 

</body>

</html> ";

 

$para = '[email protected]';

$asunto = 'Cotizacion desde demo1';

mail($para,$asunto,$cuerpomail,$header);

?>

 

 

 

Y este el el formulario. No esta terminado el aspecto visual pero el code esta listo

 

 

 

 

<!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>

<style type="text/css">

<!--

.Estilo1 {

color: #FFFFFF;

font-weight: bold;

}

-->

</style>

</head>

 

<body>

<form action="cotiza.php" method="post" name="cotiza">

<table width="67%" border="0">

<tr>

<td colspan="6" bgcolor="#000000"><div align="center" class="Estilo1">DATOS CLIENTE</div></td>

</tr>

<tr>

<td width="13%">NOMBRE</td>

<td colspan="5"><input name="nombre" type="text" size="80" id="nombre"/>

 </td>

</tr>

<tr>

<td>DIRECCION</td>

<td colspan="5"><input name="direccion" type="text" size="80" id="direccion"/></td>

</tr>

<tr>

<td>EMAIL</td>

<td colspan="5"><input name="email" type="text" size="80" id="email"/></td>

</tr>

<tr>

<td>TELEFONO</td>

<td colspan="2"><input name="telefono" type="text" size="20" id="telefono"/></td>

<td width="13%"> </td>

<td colspan="2"> </td>

</tr>

<tr>

<td colspan="6" bgcolor="#000000"><div align="center" class="Estilo1"><strong>DETALLE DE SU RECETA</strong></div></td>

</tr>

<tr>

<td><div align="center"><strong>LEJOS</strong></div></td>

<td width="14%"><div align="center"><strong>CIL</strong></div></td>

<td width="14%"><div align="center"><strong>ESF</strong></div></td>

<td width="14%"><div align="center"><strong>EJE</strong></div></td>

<td width="14%"><div align="center"><strong>PRISMA</strong></div></td>

<td width="34%"><div align="center"></div></td>

</tr>

<tr>

<td><strong>O.D.</strong></td>

<td><input name="lodcil" type="text" id="lodcil" size="10"/></td>

<td><input name="lodesf" type="text" id="lodesf" size="10"/></td>

<td><input name="lodeje" type="text" id="lodeje" size="10"/></td>

<td><input name="lodpris" type="text" id="lodpris" size="10"/></td>

<td> </td>

</tr>

<tr>

<td><strong>O.I.</strong></td>

<td><input name="loicil" type="text" id="loicil" size="10"/></td>

<td><input name="loiesf" type="text" id="loiesf" size="10"/></td>

<td><input name="loieje" type="text" id="loieje" size="10"/></td>

<td><input name="loipris" type="text" id="loipris" size="10"/></td>

<td> </td>

</tr>

<tr>

<td><strong>D.P</strong></td>

<td colspan="3"><input name="lejosdp" type="text" id="lejosdp" size="20"/></td>

<td> </td>

<td> </td>

</tr>

<tr>

<td><div align="center"><strong>CERCA</strong></div></td>

<td><div align="center"><strong>CIL</strong></div></td>

<td><div align="center"><strong>ESF</strong></div></td>

<td><div align="center"><strong>EJE</strong></div></td>

<td><div align="center"><strong>PRISMA</strong></div></td>

<td><div align="center"></div></td>

</tr>

<tr>

<td><strong>O.D.</strong></td>

<td><input name="codcil" type="text" id="codcil" size="10"/></td>

<td><input name="codesf" type="text" id="codesf" size="10"/></td>

<td><input name="codeje" type="text" id="codeje" size="10"/></td>

<td><input name="codpris" type="text" id="codpris" size="10"/></td>

<td> </td>

</tr>

<tr>

<td><strong>O.I.</strong></td>

<td><input name="coicil" type="text" id="coicil" size="10"/></td>

<td><input name="coiesf" type="text" id="coiesf" size="10"/></td>

<td><input name="coieje" type="text" id="lcoieje" size="10"/></td>

<td><input name="loipris" type="text" id="loipris" size="10"/></td>

<td> </td>

</tr>

<tr>

<td><strong>D.P.</strong></td>

<td colspan="3"><input name="cercadp" type="text" id="carcadp" size="20"/></td>

<td> </td>

<td> </td>

</tr>

<tr>

<td colspan="6"> </td>

</tr>

<tr>

<td colspan="6" bgcolor="#000000"><div align="center" class="Estilo1"><strong>TRATAMIENTOS</strong></div></td>

</tr>

<tr>

<td colspan="2">TIPO DE CRISTAL</td>

<td colspan="4"><select name="tipocris" size="1">

<option selected="selected">Monofocal</option>

<option>Bifocal</option>

<option>Multifocal</option>

</select></td>

</tr>

<tr>

<td height="24" colspan="2">MATERIAL CRISTAL</td>

<td colspan="4"><select name="material" size="1">

<option value="mineral">Mineral</option>

<option value="organico" selected="selected">Organico</option>

<option value="policarbonato">Policarbonato</option>

<option value="highLite">High Lite</option>

 

</select></td>

</tr>

<tr>

<td colspan="2">TRATAMIENTOS </td>

<td colspan="4"><input name="antireflex" type="radio" value="antireflex" />

Antireflex  <input name="duralux" type="radio" value="duralux" />

Duralux  <input name="foto" type="radio" value="fotocromaticos" /> Fotocromáticos  <input name="filtro" type="radio" value="filtro" />Filtro UV UVA</td>

</tr>

<tr>

<td colspan="6"> </td>

</tr>

<tr>

<td colspan="6" bgcolor="#000000"><div align="center" class="Estilo1"><strong>ARMAZON</strong></div></td>

</tr>

<tr>

<td colspan="3">ARMAZON OFERTA</td>

<td colspan="3"><select name="oferta" id="oferta">

<option value="Cotizar con Armazon Economico">Cotizar con Armazon Economico</option>

<option value="Cotizar con Armazon Economico Semi-Aire">Cotizar con Armazon Economico Semi-Aire</option>

<option value="Cotizar con Armazon Economico al Aire">Cotizar con Armazon Economico al Aire</option>

<option value="Cotizar con Armazon Economico Celuloide">Cotizar con Armazon Economico Celuloide</option>

<option value="Cotizar con Armazon Economico Niño">Cotizar con Armazon Economico Niño</option>

</select></td>

</tr>

<tr>

<td colspan="3"><strong>ARMAZON DESDE CATALOGO</strong></td>

<td colspan="2"> </td>

<td> </td>

</tr>

<tr>

<td>MARCA</td>

<td colspan="2"><input name="marca" type="text" id="marca" size="20"/></td>

<td colspan="2"><div align="center">MODELO</div></td>

<td><input name="modelo" type="text" id="modelo"/></td>

<tr>

<td></td>

<td colspan="2"></td>

<td colspan="2"></td>

<td></td>

</tr>

</tr>

</table>

<input name="enviar" type="submit" />

</form>

</body>

</html>

 

 

 

Gracias por su ayuda amigos! :bravo:

Edited by panchompc
Link to comment
Share on other sites

Estimado.

 

Esta Bien tu codigo, Pero:

 

* No es necesario que en el cuerpo del correo escribas <html> y <body>, ya que estarias instanciando dos <html> y <body>, el primero es el central de cualquier pagina de correo que tengas mas el que tienes ahora, igual te funcionaria pero no es necesario.

 

* Siempre te debes fijar como iniciar las variables de texto o los echo, ejemplo.

si empiezas con dobles comillas termina con doble comillas y las variables que concatenes tambien tiene que ser con doble comilla.

 

$variable = "(texto lalalala)". $variable1. "sigue texto";

$ejemplo = 'texto lalalala'. $variable_que_concateno .' kalalalallala';

 

Esop..

 

En tu codigo deberia ser asi.

 

$cuerpomail = "

<P>MENSAJE ENVIADO POR: ".$_POST['nombre']."| SU EMAIL ES: ".$_POST['email']." <br />
SU DIRECCION ES: ".$_POST['direccion']." | Y SU TELEFONO ES: ".$_POST['telefono']."</P>

<P>LENTE LEJOS <BR />
OD ESF: ".$_POST['lodesf']." | CIL: ".$_POST['lodcil']." | EJE:".$_POST['lodeje']." | PRISMA: ".$_POST['lodpris']." <BR />
OI ESF: ".$_POST['loiesf']." | CIL :".$_POST['loicil']." | EJE:".$_POST['loieje']." | PRISMA: ".$_POST['loipris']." <BR />
DP: ".$_POST['lejosdp']."

//** NO E CONTINUADO PORQUE SON COMO 30 DATOS MAS DESDE EL FORMULARIO **\\

";

 

 

Suerte.

 

 

 

 

 

 

Link to comment
Share on other sites

Segui tu recomendacion y cambie las comillas segun el ejemplo que editaste, pero sigue saliendo el mismo error:

 

"Parse error: syntax error, unexpected T_VARIABLE in /home/vhosts/**SITIO**/cotiza.php on line 13"

 

 

hay otra forma de ordenar datos en texto plano??

 

ejemplo

 

*TEXTO* + &dato1 ___ espacio___ *TEXTO* + &dato2

__SALTO LINEA__

*TEXTO* + &dato3 ___ espacio___ *TEXTO* + &dato4

 

ETC .....

 

la idea es que quede asi cuando llege el mail:

______________________________________________

 

Cotizacion desde *******:

 

Datos contacto: Nombre , telefono, direccion , etc

 

Sus datos de receta son:

 

Lente lejos:

OD ESF dato1 | CIL dato2 |EJE dato3 etc.....

OI ESF dato1 | CIL dato2 |EJE dato3 etc.....

 

Lente Cerca

OD ESF dato1 | CIL dato2 |EJE dato3 etc.....

OI ESF dato1 | CIL dato2 |EJE dato3 etc....

 

 

Eso, Gracias por su Ayuda!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...