Hola, tengo un formulario hecho en flash donde uso dos combobox, ciudades y oficinas, dependiendo la ciudad que el usuario escoja lo lleva al combobox con su respectiva lista de oficinas, el problema está cuando defino variables, ya que al enviar el formulario envía todas las variables, incluyendo las que el usuario no elige, y como no las elige quedan como undefined en el mail, es decir queda algo así:
Nombre: Alex
E-mail: [email protected]
No. Teléfono: 8648205
No. Celular: 3124233708
Mensaje: el mensaje
Ciudad: Barranquilla
Oficina
undefined
undefined
oficina 01
undefined
undefined
undefined
este es el actionscript
stop ();
System.useCodepage = true;
send_btn.onRelease = function ()
{
my_vars = new LoadVars();
my_vars.company = cname.text;
my_vars.nam = pname.text;
my_vars.messag = desi.text;
my_vars.email = email.text;
my_vars.tel = tel.text;
my_vars.cat = cat.text;
my_vars.catarmenia = catarmenia.setSelected();
if (my_vars.catarmenia == true)
{
my_vars.temp_varcatarmenia = catarmenia.getLabel();
}
else
{
delete my_vars.temp_varcatarmenia;
}
my_vars.catbarranca = catbarranca.setSelected();
if (my_vars.catbarranca == true)
{
my_vars.temp_varcatbarranca = catbarranca.getLabel();
}
else
{
delete my_vars.temp_catbarranca;
}
my_vars.catbarranquilla = catbarranquilla.setSelected();
if (my_vars.catbarranquilla == true)
{
my_vars.temp_varcatbarranquilla = catbarranquilla.getLabel();
}
else
{
delete my_vars.temp_catbarranquilla;
}
my_vars.catbogota = catbogota.setSelected();
if (my_vars.catbogota == true)
{
my_vars.temp_varcatbogota = catbogota.getLabel();
}
else
{
delete my_vars.temp_catbogota;
}
my_vars.catbuca = catbuca.text;
my_vars.catcali = catcali.text;
my_vars.catcarta = catcarta.text;
my_vars.catcauca = catcauca.text;
my_vars.catchia = catchia.text;
my_vars.catcucuta = catcucuta.text;
my_vars.catenvigado = catenvigado.text;
my_vars.catibague = catibague.text;
my_vars.catitagui = catitagui.text;
my_vars.catmani = catmani.text;
my_vars.catmedellin = catmedellin.text;
my_vars.catmonteria = catmonteria.text;
my_vars.catpasto = catpasto.text;
my_vars.catpereira = catpereira.text;
my_vars.catpopayan = catpopayan.text;
my_vars.catrionegro = catrionegro.text;
my_vars.catsanta = catsanta.text;
my_vars.cattunja = cattunja.text;
my_vars.catvilla = catvilla.text;
my_vars.acepto = acepto.text;
if (my_vars.company != "" && my_vars.nam != "" && my_vars.messag != "" && my_vars.email != "" && my_vars.tel != "" && my_vars.cat != "" && my_vars.catarmenia != "" && my_vars.temp_varcatarmenia != "" && my_vars.catbarranca != "" && my_vars.temp_varcatbarranca != "" && my_vars.catbarranquilla != "" && my_vars.temp_varcatbarranquilla != "" && my_vars.catbogota != "" && my_vars.temp_varcatbogota != "" && my_vars.catbuca != "" && my_vars.catcali != "" && my_vars.catcarta != "" && my_vars.catcauca != "" && my_vars.catchia != "" && my_vars.catcucuta != "" && my_vars.catenvigado != "" && my_vars.catibague != "" && my_vars.catitagui != "" && my_vars.catmani != "" && my_vars.catmedellin != "" && my_vars.catmonteria != "" && my_vars.catpasto != "" && my_vars.catpereira != "" && my_vars.catpopayan != "" && my_vars.catrionegro != "" && my_vars.catsanta != "" && my_vars.cattunja != "" && my_vars.catvulla != "" && my_vars.acepto != "")
{
my_vars.sendAndLoad("mailer.php", my_vars, "GET");
gotoAndStop(230);
}
else
{
error_clip.gotoAndPlay(2);
} // end else if
my_vars.onLoad = function ()
{
gotoAndStop(231);
};
};
acepto.onSetFocus = cname.onSetFocus = pname.onSetFocus = desi.onSetFocus = email.onSetFocus = tel.onSetFocus = function ()
{
if (error_clip._currentframe != 1)
{
error_clip.gotoAndPlay(6);
} // end if
};
resr.onRelease = function ()
{
cname.text = "";
pname.text = "";
desi.text = "";
email.text = "";
tel.text = "";
catarmenia.selected = false;
catbarranca.selected = false;
catbarranquilla.selected = false;
catbogota.selected = false;
}
intenté las 4 primeras diciendo que creara la variable solo si escojen el combobox pero al parecer hay algo mal, ya que así no envia ninguna variable
este es el codigo php, es decir mailer.php
<?php
$company=$_REQUEST["company"];
$name=$_REQUEST["nam"];
$desi=$_REQUEST["messag"];
$email=$_REQUEST["email"];
$tel=$_REQUEST["tel"];
$cat=$_REQUEST["cat"];
$catarmenia=$_REQUEST["temp_varcatarmenia"];
$catbarranca=$_REQUEST["temp_varcatbarranca"];
$catbarranquilla=$_REQUEST["temp_varcatbarranquilla"];
$catbogota=$_REQUEST["temp_varcatbogota"];
$catbuca=$_REQUEST["catbuca"];
$catcali=$_REQUEST["catcali"];
$catcarta=$_REQUEST["catcarta"];
$catcauca=$_REQUEST["catcauca"];
$catchia=$_REQUEST["catchia"];
$catcucuta=$_REQUEST["catcucuta"];
$catenvigado=$_REQUEST["catenvigado"];
$catibague=$_REQUEST["catibague"];
$catitagui=$_REQUEST["catitagui"];
$catmani=$_REQUEST["catmani"];
$catmedellin=$_REQUEST["catmedellin"];
$catmonteria=$_REQUEST["catmonteria"];
$catpasto=$_REQUEST["catpasto"];
$catpereira=$_REQUEST["catpereira"];
$catpopayan=$_REQUEST["catpopayan"];
$catrionegro=$_REQUEST["catrionegro"];
$catsanta=$_REQUEST["catsanta"];
$cattunja=$_REQUEST["cattunja"];
$catvilla=$_REQUEST["catvilla"];
$subject = $_REQUEST["subject"];
$mess = $_REQUEST["company"];
$sender = $_REQUEST["email"];
// don't play with the header
function send_email($from, $to, $subject, $message){
$headers = "From: ".$from."\r\n";
$headers .= "Reply-To: ".$from."\r\n";
$headers .= "Return-Path: ".$from."\r\n";
$headers .= "Content-type: text/html\r\n";
if (mail($to,$subject,$message,$headers) ) {
echo "email sent";
} else {
echo "email couldn't be sent";
}
}
// put the email subject at here
$subject = "Enquiry form";
$message .= "<html>";
$message .="<head>\n";
$message .= "<style type=text/css>\n";
$message .=".style6 {\n";
$message .="font-size: 10px;\n";
$message .="font-family: Verdana, Arial, Helvetica, sans-serif;\n";
$message .="color: #333333;\n";
$message .="}\n";
$message .=".style7 {\n";
$message .="font-family: Verdana, Arial, Helvetica, sans-serif;\n";
$message .="font-size: 12px;\n";
$message .="color: #FFFFFF;\n";
$message .="font-weight: bold;\n";
$message .="}\n";
$message .=".boarder { border: 1px solid #000000;}";
$message .=".style9 {\n";
$message .="font-family: Verdana, Arial, Helvetica, sans-serif;\n";
$message .="font-size: 10px;\n";
$message .="color: #333333;\n";
$message .="font-weight: bold\n";
$message .="}\n";
$message .="</style>\n";
$message .="</head>\n";
$message .="<body>";
//Put your company Name.
$message .= "<b>Banco Santander</b><br>\n";
$message .= "<table width=400 border=0 align=center cellpadding=0 cellspacing=0 bgcolor=#CCCCCC class=boarder>\n";
$message .= "<tr>\n";
$message .= "<td><div align=center>\n";
$message .= "<table width=400 border=0 align=center cellpadding=6 cellspacing=0 bgcolor=#CCCCCC>\n";
$message .="<tr>\n";
$message .="<td height=100 colspan=2><div align=center></div>\n";
// place the logo with your website logo and it will appeard in left side of the form.
$message .="<div align=left><img src=http://www.thebrand.com.co/santanderf/logo.jpg width=200 height=67></div></td>\n";
$message .="</tr>\n";
$message .="<tr bgcolor=#666666>\n";
$message .="<td colspan=2><div align=center class=style7>Santander Preferente </div></td>\n";
$message .="</tr>\n";
$message .="<tr>\n";
$message .="<td width=120 class=style6><span class=style9>Nombre:</span></td>\n";
$message .="<td><div align=left class=style6>".$company."</div></td>\n";
$message .="</tr>\n";
$message .="<tr>\n";
$message .="<td class=style9>E-mail: </td>\n";
$message .="<td class=style6><div align=left>".$name."</div></td>\n";
$message .="</tr>";
$message .="<tr>";
$message .="<td class=style9>No. Teléfono:</td>\n";
$message .="<td class=style6><div align=left>".$messag."</div></td>\n";
$message .="</tr>\n";
$message .="<tr>\n";
$message .="<td class=style9>No. Celular: </td>\n";
$message .="<td class=style6><div align=left>".$email."</div></td>\n";
$message .="</tr>\n";
$message .="<tr>\n";
$message .="<td class=style9>Mensaje: </td>\n";
$message .="<td class=style6><div align=left>".$tel."</div></td>\n";
$message .="</tr>\n";
$message .="<tr>\n";
$message .="<td class=style9>Ciudad: </td>\n";
$message .="<td class=style6><div align=left>".$cat."</div></td>";
$message .="</tr>\n";
$message .="<tr>\n";
$message .="<tr bgcolor=#666666>\n";
$message .="<td colspan=2><div align=center class=style7>\n";
$message .="<div align=left>Oficina</div>\n";
$message .="</div></td>\n";
$message .="</tr>\n";
$message .="<tr>\n";
$message .="<td colspan=2><div align=left class=style6><table width=90% border=0 cellspacing=0 cellpadding=0>\n";
$message .="<tr>\n";
$message .="<td class=style6>".$catarmenia."</td>\n";
$message .= "</tr>\n";
$message .="<td class=style6>".$catbarranca."</td>\n";
$message .= "</tr>\n";
$message .="<td class=style6>".$catbarranquilla."</td>\n";
$message .= "</tr>\n";
$message .="<td class=style6>".$catbogota."</td>\n";
$message .= "</tr>\n";
$message .="</table></div></td>\n";
$message .="</tr>\n";
$message .="</table>\n";
$message .="</div></td>\n";
$message .="</tr>\n";
$message .="</table>\n";
// put your email address here!
send_email("[email protected]", "[email protected]",
$subject ,
$message);
?>
Les agradecería MUCHISIMO si me pueden ayudar!!