Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/07/2011, 03:38
AJDC
 
Fecha de Ingreso: agosto-2003
Mensajes: 324
Antigüedad: 20 años, 9 meses
Puntos: 1
Seleccionar la opción de un select

Saludos...
Tengo un php que hace de formulario, y cuyos datos envío luego por correo. Quiero que sea todo en una misma página...
Todo funciona bien, la recogida de datos, el envío.. excepto.... los datos de un campo select, que no me los "pilla"....

¿Cómo puedo hacerlo?.. Muchas gracias...

Pego el código...
Código PHP:
<!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>
<link rel="stylesheet" href="******template.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Formulario de Contacto Inversores</title>

<style type="text/css">
TD.EtiquetaCampo{
    font-family: Arial;
    font-size: 10px;
    color: #666;
    width: 120px;
    text-align: right;
    padding-bottom: 5px;
    vertical-align: middle;
}
TD.Campo{
    width: 200px;
    font-family: Arial;
    font-size: 10px;
    color: #666;
    padding-bottom: 5px;
    padding-left: 5px;
}
TD.CampoD{
    width: 528px;
    font-family: Arial;
    font-size: 10px;
    color: #666;
    padding-bottom: 5px;
    padding-left: 5px;
}
TD.CampoSelect{
    padding-left: 5px;
}
TD.BotonEnviar{
    width: 630px;
    text-align: right;
}
input { 
    font-family: Arial;
    font-size: 11px;
    color: #003580;
    background-color: #FBFCF0;
    border: #DDE485;
    border-style: solid;
    border-top-width: 1px;
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px;
    width: 200px;
}
input#enviar { 
    font-family: Arial;
    font-size: 11px;
    color: #003580;
    background-color: #DDE485;
    border: #DDE485;
    border-style: solid;
    border-top-width: 1px;
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px;
    width: 60px;
    cursor: pointer;
}
input.campodireccion{
    width: 528px;
}
select {
    font-family: Arial;
    font-size: 11px;
    color: #003580;
    background-color: #FBFCF0;
    border: #DDE485;
    border-style: solid;
    border-top-width: 1px;
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px
}
-->



</style>
</head>

<body>

<?php session_start(); ?>
  <form action="" method="post">
  <table width="620" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="EtiquetaCampo">*Nombre</td>
    <td class="Campo"><input name="nombre" type="text" value="<?php if(isset($_POST["nombre"])) {echo $_POST["nombre"];} ?>"></td>
    <td class="EtiquetaCampo">*Apellidos</td>
    <td class="Campo"><input name="apellidos" type="text"  value="<?php if(isset($_POST["apellidos"])) {echo $_POST["apellidos"];} ?>"></td>  
  </tr>

  <tr>
    <tr>
    <td class="EtiquetaCampo">*correo-e</td>
    <td class="Campo"><input name="correoe" type="text" value="<?php if(isset($_POST["correoe"])) {echo $_POST["correoe"];} ?>"></td>
    <td class="EtiquetaCampo">*DNI</td>
    <td class="Campo"><input name="dni" type="text" value="<?php if(isset($_POST["dni"])) {echo $_POST["dni"];} ?>"></td>
  </tr>
  
  <tr>
    <td class="EtiquetaCampo">*Telf. contacto 1</td>
    <td class="Campo"><input name="telefono1" type="text" value="<?php if(isset($_POST["telefono1"])) {echo $_POST["telefono1"];} ?>"></td>
    <td class="EtiquetaCampo">Telf. contacto 2</td>
    <td class="Campo"><input name="telefono2" type="text" value="<?php if(isset($_POST["telefono2"])) {echo $_POST["telefono2"];} ?>"></td>
  </tr>

  <tr>
    <td class="EtiquetaCampo">Empresa</td>
    <td class="Campo"><input name="empresa" type="text" value="<?php if(isset($_POST["empresa"])) {echo $_POST["empresa"];} ?>"></td>
      <td class="EtiquetaCampo">CIF</td>
    <td class="Campo"><input name="cif" type="text" value="<?php if(isset($_POST["cif"])) {echo $_POST["cif"];} ?>"></td>
  </tr>
  <tr>
    <td class="EtiquetaCampo">*Direcci&oacute;n</td>
    <td colspan="3" class="CampoD"><input name="direccion" type="text" value="<?php if(isset($_POST["direccion"])) {echo $_POST["direccion"];} ?>" class="campodireccion"></td>
  </tr>

  <tr>
    <td class="EtiquetaCampo">*CP</td>
    <td class="Campo"><input name="cp" type="text" value="<?php if(isset($_POST["cp"])) {echo $_POST["cp"];} ?>"></td>
    <td class="EtiquetaCampo">*Localidad</td>
    <td class="Campo"><input name="localidad" type="text" value="<?php if(isset($_POST["localidad"])) {echo $_POST["localidad"];} ?>"></td>
  </tr>
  
  <tr>
    <td class="EtiquetaCampo">*Provincia</td>
    <td class="Campo"><input name="provincia" type="text" value="<?php if(isset($_POST["provincia"])) {echo $_POST["provincia"];} ?>"></td>
    <td class="EtiquetaCampo">*Pa&iacute;s</td>
    <td class="Campo"><input name="pais" type="text" value="<?php if(isset($_POST["pais"])) {echo $_POST["pais"];} ?>"></td>
  </tr>
   <tr>
    <td class="EtiquetaCampo"><BR /></td>
    <td class="Campo"><BR /></td>
    <td class="EtiquetaCampo"><BR /></td>
    <td class="Campo"><BR /></td>
  </tr>

   <tr>
    <td class="EtiquetaCampo" colspan= "2">*Inversiones de inter&eacute;s</td>
    <td class="CampoSelect" colspan= "2"><SELECT NAME="inversiones">
  <option selected>--- SELECCIONE UNA OPCION ---
  <option value="viviendas" >Viviendas
  <option value="locales">Locales
  <option value="naves">Naves
  <option value="solares">Solares
  <option value="fincas rusticas">Fincas r&uacute;sticas
  <option value="otros">Otros
  </SELECT>
   </td>
  </tr>
   </table>
   <br /><br />
  <table width="630px" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="BotonEnviar"><input name="action" type="hidden" value="send"><input name="enviar" type="submit" value="Enviar" id="enviar"></td>
  </tr>
  </table>
  </form>
  
  
  <?php
  
      
if (isset($_POST['action'])) {
  
       
$dest "[email protected]";
       
$head "From: ".$_POST['nombre']." ".$_POST['apellidos']."<".$_POST['correoe'].">\r\n";
       
$asunto "Datos nuevo inversor desde formulario web";
       
$email $_POST['correoe'];
  
       
// CUERPO DEL MENSAJE
    
$msg "----------------------------------------- \n";
    
$msg.= "            Datos de Contacto             \n";
    
$msg.= "----------------------------------------- \n";
    
$msg.= "Correo-e:   ".$_POST['correoe']."\n";
    
$msg.= "NOMBRE:   ".$_POST['nombre']." ".$_POST['apellidos']."\n";
    
$msg.= "TELEFONO 1: ".$_POST['telefono1']."\n";
    
$msg.= "TELEFONO 2: ".$_POST['telefono2']."\n";
    
$msg.= "DNI:  ".$_POST['dni']."\n";
    
    
$msg.= "EMPRESA:  ".$_POST['empresa']."\n";
    
$msg.= "CIF:  ".$_POST['cif']."\n";
    
    
$msg.= "DIRECCION:  ".$_POST['direccion']."\n";
    
$msg.= "LOCALIDAD:  ".$_POST['localidad']."\n";
    
    
$msg.= "CP:  ".$_POST['cp']."\n";
    
$msg.= "PROVINCIA:  ".$_POST['provincia']."\n";
    
$msg.= "PAIS:     ".$_POST['pais']."\n\n\n";
       
    
$msg.= "INVERSIONES DE INTERES:  ".$_POST['inversiones']."\n\n\n";
     
      
    
$msg.= "HORA:     ".date("h:i:s a ")."\n";
    
$msg.= "FECHA:    ".date("D, d M Y")."\n";

  
  
       
// CAMPOS REQUERIDOS
       
if(empty($_POST['nombre'])) die("El campo Nombre es requerido");
       if(empty(
$_POST['apellidos'])) die("El campo Primer Apellidos es requerido");
       if(empty(
$_POST['telefono1'])) die("El campo Telefono 1 es requerido");
       if(empty(
$_POST['dni'])) die("El campo DNI es requerido");
       if(empty(
$_POST['direccion'])) die("El campo Direccion es requerido");
       if(empty(
$_POST['localidad'])) die("El campo Localidad es requerido");
       if(empty(
$_POST['cp'])) die("El campo CP es requerido");
       if(empty(
$_POST['provincia'])) die("El campo Provincia es requerido");
       if(empty(
$_POST['pais'])) die("El campo Pais es requerido");
       if(empty(
$_POST['inversiones'])) die("El campo Inversiones de Interes es requerido");
    
    
  
       
// VALIDAR EMAIL
       //function validarCorreo($email)
       //{
        //   re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3,4})+$/.test(valor);
         //  return re;
       //return eregi('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([a-z0-9]+[\.-])*[a-z0-9]+\.[a-z]{2,6}$',$email);
       //}
       
  
function comprobar_email($email){
    
$mail_correcto 0;
    
//compruebo unas cosas primeras
    
if ((strlen($email) >= 6) && (substr_count($email,"@") == 1) && (substr($email,0,1) != "@") && (substr($email,strlen($email)-1,1) != "@")){
       if ((!
strstr($email,"'")) && (!strstr($email,"\"")) && (!strstr($email,"\\")) && (!strstr($email,"\$")) && (!strstr($email," "))) {
          
//miro si tiene caracter .
          
if (substr_count($email,".")>= 1){
             
//obtengo la terminacion del dominio
             
$term_dom substr(strrchr ($email'.'),1);
             
//compruebo que la terminación del dominio sea correcta
             
if (strlen($term_dom)>&& strlen($term_dom)<&& (!strstr($term_dom,"@")) ){
                
//compruebo que lo de antes del dominio sea correcto
                
$antes_dom substr($email,0,strlen($email) - strlen($term_dom) - 1);
                
$caracter_ult substr($antes_dom,strlen($antes_dom)-1,1);
                if (
$caracter_ult != "@" && $caracter_ult != "."){
                   
$mail_correcto 1;
                }
             }
          }
       }
    }
  }
    
       if(
$mail_correcto) { }
       else { die (
'Su E-mail no es valido, verifiquelo e intentelo nuevamente.'); }
  

    
    
      
  
       
// ENVIO DEL MENSAJE
       
if (mail($dest$asunto$msg$head)) {
       echo 
"Su mensaje fue enviado, pronto estaremos en contacto. Gracias.";
       } else {
       echo 
"Error de envio, intentelo nuevamente.";
       }
       }
  
  
?>


</body>
</html>