Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/05/2011, 05:15
Avatar de iPiti
iPiti
 
Fecha de Ingreso: abril-2011
Mensajes: 6
Antigüedad: 13 años
Puntos: 0
PHP para un select name

Hola a todos,
no sé hacer que me llegue la opción elegida en un campo select name de un formulario. si alguien me pudiera ayudar se lo agradecería enormemente.

Aquí os dejo el <form> del archivo html y el PHP:

<form id="freeform" name="a" method="post" action="enviarmail.php" >
<label id="freeform_name_label" for="name">Nombre</label>
<input type="text" id="freeform_name" name="name" />
<label id="freeform_email_label" for="email">Email</label>
<input type="text" id="freeform_email" name="email" />
<label id="freeform_subject_label" for="subject">Asunto</label>
<input type="text" id="freeform_subject" name="subject" />
<label id="freeform_topic_label" for="topic[]">Tema</label>
<select name="topic[]" id="freeform_topic" />
<option value="Oferta de producto">Oferta de producto / negocio</option>
<option value="Propuesta de ideas">Propuesta de ideas</option>
<option value="Pedido">Pedido</option>
<option value="Informacion">Informaci&oacute;n</option>
<option value="Solicitud de Newsletters">Solicitud de Newsletters</option>
<option value="Otros">Otros</option>
</select>
<label id="freeform_question_label" for="question">Cuesti&oacute;n</label>
<textarea name="question" id="freeform_question"></textarea>
<input type="submit" id="submit" name="submit" class="button large" value="Enviar Mensaje &gt;" />
</form>

----------------

<?
$name = $_POST['name'];
$email = $_POST['email'];
$asunto = $_POST['subject'];
$topic = $_POST['topic[]'];

$header = 'From: ' . $email . " \r\n";
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";
$asunto = 'Correo desde la web';

$mensaje = "Nombre: " . $_POST['name'] . " \r\n";
$mensaje .= "E-mail: " . $_POST['email'] . " \r\n";
$mensaje .= "Motivo: " . $_POST['topic'] . " \r\n";
$mensaje .= "Cuestion: " . $_POST['question'] . " \r\n";

$para = '[email protected]';

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

echo 'Su solicitud ha sido enviada con éxito. En breve recibirá noticias de XXX atendiendo su petición. Muchas gracias.'

?>