Forma básica - e-mail enviado basada en menú desplegable, seleccione la opción
- jennifer420
- Born


- Registrado: Jul 16, 2009
- Mensajes: 3
- Status: Offline
Hola,
Mis disculpas si esto ya se ha publicado, Ive buscó por todas partes (google, etc), así como la lectura de este post: website-design-forum/multiple-email-addresses-one-form-t21891.html pero sólo parece que no puede hacerlo bien.
Mi formulario tiene un menú desplegable en ella donde la gente puede seleccionar una ciudad...y cada ciudad tiene su propio correo electrónico.
Por ejemplo:
Si la ciudad "Mathis" es seleccionado, entonces un correo electrónico irá a x@mathis.com
Si se selecciona la ciudad de Orange Grove, a continuación, un correo electrónico irá a x@orangegrove.com
y así sucesivamente...
A continuación se muestra cuando Im con él en la forma, pero no puedo hacer que esto funcione.
Id realmente agradecería cualquier ayuda con esto, muchas gracias...
Jennifer
Mis disculpas si esto ya se ha publicado, Ive buscó por todas partes (google, etc), así como la lectura de este post: website-design-forum/multiple-email-addresses-one-form-t21891.html pero sólo parece que no puede hacerlo bien.
Mi formulario tiene un menú desplegable en ella donde la gente puede seleccionar una ciudad...y cada ciudad tiene su propio correo electrónico.
Por ejemplo:
Si la ciudad "Mathis" es seleccionado, entonces un correo electrónico irá a x@mathis.com
Si se selecciona la ciudad de Orange Grove, a continuación, un correo electrónico irá a x@orangegrove.com
y así sucesivamente...
A continuación se muestra cuando Im con él en la forma, pero no puedo hacer que esto funcione.
Id realmente agradecería cualquier ayuda con esto, muchas gracias...
Código: [ Select ]
<?php
$EmailFrom = "xxx";
$EmailTo = "xxx";
if (Locations===Marthis) {
mailto = "x@mathis.com";
} else if (Locations===Orange Grove) {
mailto = "x@og.com";
}
$Subject = "Customer Request";
$locations= htmlspecialchars(Trim(stripslashes($_POST['Locations'])));
$Name = htmlspecialchars(Trim(stripslashes($_POST['Name'])));
$Phone = htmlspecialchars(Trim(stripslashes($_POST['Phone'])));
$Email = htmlspecialchars(Trim(stripslashes($_POST['Email'])));
$Message = htmlspecialchars(Trim(stripslashes($_POST['Message'])));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Location: ";
$Body .= $Locations;
$Body .= "\n";
$Body .= "Request: ";
$Body .= $Request;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=submit.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
$EmailFrom = "xxx";
$EmailTo = "xxx";
if (Locations===Marthis) {
mailto = "x@mathis.com";
} else if (Locations===Orange Grove) {
mailto = "x@og.com";
}
$Subject = "Customer Request";
$locations= htmlspecialchars(Trim(stripslashes($_POST['Locations'])));
$Name = htmlspecialchars(Trim(stripslashes($_POST['Name'])));
$Phone = htmlspecialchars(Trim(stripslashes($_POST['Phone'])));
$Email = htmlspecialchars(Trim(stripslashes($_POST['Email'])));
$Message = htmlspecialchars(Trim(stripslashes($_POST['Message'])));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Location: ";
$Body .= $Locations;
$Body .= "\n";
$Body .= "Request: ";
$Body .= $Request;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=submit.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
- <?php
- $EmailFrom = "xxx";
- $EmailTo = "xxx";
- if (Locations===Marthis) {
- mailto = "x@mathis.com";
- } else if (Locations===Orange Grove) {
- mailto = "x@og.com";
- }
- $Subject = "Customer Request";
- $locations= htmlspecialchars(Trim(stripslashes($_POST['Locations'])));
- $Name = htmlspecialchars(Trim(stripslashes($_POST['Name'])));
- $Phone = htmlspecialchars(Trim(stripslashes($_POST['Phone'])));
- $Email = htmlspecialchars(Trim(stripslashes($_POST['Email'])));
- $Message = htmlspecialchars(Trim(stripslashes($_POST['Message'])));
- // validation
- $validationOK=true;
- if (!$validationOK) {
- print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
- exit;
- }
- // prepare email body text
- $Body = "";
- $Body .= "Name: ";
- $Body .= $Name;
- $Body .= "\n";
- $Body .= "Phone: ";
- $Body .= $Phone;
- $Body .= "\n";
- $Body .= "Email: ";
- $Body .= $Email;
- $Body .= "\n";
- $Body .= "Location: ";
- $Body .= $Locations;
- $Body .= "\n";
- $Body .= "Request: ";
- $Body .= $Request;
- $Body .= "\n";
- // send email
- $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
- // redirect to success page
- if ($success){
- print "<meta http-equiv=\"refresh\" content=\"0;URL=submit.htm\">";
- }
- else{
- print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
- }
- ?>
Jennifer
- Anonymous
- Bot


- Registrado: 25 Feb 2008
- Mensajes: ?
- Loc: Ozzuland
- Status: Online
Julio 16th, 2009, 12:19 pm
- UPSGuy
- Lurker ಠ_ಠ


- Registrado: Jul 25, 2005
- Mensajes: 2735
- Loc: Nashville, TN
- Status: Offline
Código: [ Select ]
if (Locations===Marthis) {
mailto = "x@mathis.com";
} else if (Locations===Orange Grove) {
mailto = "x@og.com";
}
- if (Locations===Marthis) {
- mailto = "x@mathis.com";
- } else if (Locations===Orange Grove) {
- mailto = "x@og.com";
- }
¿Qué es Locations supone que es? Si la de la forma, entonces esto es más lo que está buscando:
Código: [ Select ]
<?php
$EmailFrom = "xxx";
$EmailTo = "xxx";
$Subject = "Customer Request";
$Locations= htmlspecialchars(trim(stripslashes($_POST['Locations'])));
$Name = htmlspecialchars(trim(stripslashes($_POST['Name'])));
$Phone = htmlspecialchars(trim(stripslashes($_POST['Phone'])));
$Email = htmlspecialchars(trim(stripslashes($_POST['Email'])));
$Message = htmlspecialchars(trim(stripslashes($_POST['Message'])));
switch($Locations) {
case "Marthis":
$mailto = "x@mathis.com";
break;
case "Orange Grove":
$mailto = "x@og.com";
break;
default:
$mailto = "yourSiteAdminAddyHereToCatchInvalidLocations@site.com";
break;
}
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "Name: $Name\n";
$Body .= "Phone: $Phone\n";
$Body .= "Email: $Email\n";
$Body .= "Location: $Locations\n";
$Body .= "Request: $Request\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=submit.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
- <?php
- $EmailFrom = "xxx";
- $EmailTo = "xxx";
- $Subject = "Customer Request";
- $Locations= htmlspecialchars(trim(stripslashes($_POST['Locations'])));
- $Name = htmlspecialchars(trim(stripslashes($_POST['Name'])));
- $Phone = htmlspecialchars(trim(stripslashes($_POST['Phone'])));
- $Email = htmlspecialchars(trim(stripslashes($_POST['Email'])));
- $Message = htmlspecialchars(trim(stripslashes($_POST['Message'])));
- switch($Locations) {
- case "Marthis":
- $mailto = "x@mathis.com";
- break;
- case "Orange Grove":
- $mailto = "x@og.com";
- break;
- default:
- $mailto = "yourSiteAdminAddyHereToCatchInvalidLocations@site.com";
- break;
- }
- // validation
- $validationOK=true;
- if (!$validationOK) {
- print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
- exit;
- }
- // prepare email body text
- $Body = "Name: $Name\n";
- $Body .= "Phone: $Phone\n";
- $Body .= "Email: $Email\n";
- $Body .= "Location: $Locations\n";
- $Body .= "Request: $Request\n";
- // send email
- $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
- // redirect to success page
- if ($success){
- print "<meta http-equiv=\"refresh\" content=\"0;URL=submit.htm\">";
- }
- else{
- print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
- }
- ?>
I condensa el contenido de su cuerpo, cambió su IFS a un interruptor adecuado / caso.
Tres cosas que usted debe recordar:
1) PHP es sensible a mayúsculas (Trim! = Trim)
2) Las variables comienzan con un signo de dólar
3) las cadenas literales debe ser incluida en las cotizaciones
I'd love to change the world, but they won't give me the source code.
- jennifer420
- Born


- Registrado: Jul 16, 2009
- Mensajes: 3
- Status: Offline
Hola UPSGuy,
Gracias...Sí, la de mi forma.
Todavía no puedo hacerlo bien aunque, Ive entró en mensajes de correo electrónico diferentes para las diferentes opciones, pero todavía no parecen ir en theyre supone.
$EmailFrom = "xxx";
$EmailTo = "xxx";
$Subject = "Customer Request";
$Locations= htmlspecialchars(trim(stripslashes($_POST['Locations'])));
$Name = htmlspecialchars(trim(stripslashes($_POST['Name'])));
$Phone = htmlspecialchars(trim(stripslashes($_POST['Phone'])));
$Email = htmlspecialchars(trim(stripslashes($_POST['Email'])));
$Message = htmlspecialchars(trim(stripslashes($_POST['Message'])));
switch($Locations) {
case "Mathis":
$mailto = "x@mathis.com";
break;
case "Orange Grove":
$mailto = "x@orangegrove.com";
break;}
Esto es mucho más complicado de lo que pensé!
Le agradezco que tomarse el tiempo para ayudar, muchas gracias »,
Jennifer
Gracias...Sí, la de mi forma.
Todavía no puedo hacerlo bien aunque, Ive entró en mensajes de correo electrónico diferentes para las diferentes opciones, pero todavía no parecen ir en theyre supone.
Código: [ Select ]
$EmailFrom = "xxx";
$EmailTo = "xxx";
$Subject = "Customer Request";
$Locations= htmlspecialchars(trim(stripslashes($_POST['Locations'])));
$Name = htmlspecialchars(trim(stripslashes($_POST['Name'])));
$Phone = htmlspecialchars(trim(stripslashes($_POST['Phone'])));
$Email = htmlspecialchars(trim(stripslashes($_POST['Email'])));
$Message = htmlspecialchars(trim(stripslashes($_POST['Message'])));
switch($Locations) {
case "Mathis":
$mailto = "x@mathis.com";
break;
case "Orange Grove":
$mailto = "x@orangegrove.com";
break;}
- $EmailFrom = "xxx";
- $EmailTo = "xxx";
- $Subject = "Customer Request";
- $Locations= htmlspecialchars(trim(stripslashes($_POST['Locations'])));
- $Name = htmlspecialchars(trim(stripslashes($_POST['Name'])));
- $Phone = htmlspecialchars(trim(stripslashes($_POST['Phone'])));
- $Email = htmlspecialchars(trim(stripslashes($_POST['Email'])));
- $Message = htmlspecialchars(trim(stripslashes($_POST['Message'])));
- switch($Locations) {
- case "Mathis":
- $mailto = "x@mathis.com";
- break;
- case "Orange Grove":
- $mailto = "x@orangegrove.com";
- break;}
Esto es mucho más complicado de lo que pensé!
Le agradezco que tomarse el tiempo para ayudar, muchas gracias »,
Jennifer
- UPSGuy
- Lurker ಠ_ಠ


- Registrado: Jul 25, 2005
- Mensajes: 2735
- Loc: Nashville, TN
- Status: Offline
Comience con algo más simple. En la parte superior de su archivo, agregue las líneas siguientes y compruebe que todo lo que se espera se está aprobada en la forma prevista:
Código: [ Select ]
foreach($_REQUEST as $key => $val) {
echo "$key: $val<br/>";
}
exit();
echo "$key: $val<br/>";
}
exit();
- foreach($_REQUEST as $key => $val) {
- echo "$key: $val<br/>";
- }
- exit();
I'd love to change the world, but they won't give me the source code.
- Bogey
- Bogey


- Registrado: Jul 14, 2005
- Mensajes: 8211
- Loc: USA
- Status: Offline
Aquí hay otra manera que usted podría hacerlo:
the_form.html
submitted.php
Sólo tiene que añadir campos a este y su validación...Ya extracción y el recorte de todos los valores presentados aquí, así que debe ser aceptable.
the_form.html
HTML Código: [ Select ]
<form action="submitted.php" method="post">
Location: <select name="location">
<option value="0">Kansas</option>
<option value="1">Alaska</option>
<option value="2">Alabama</option>
<option value="3">Kentucky</option>
<option value="4">New Jersey</option>
<option value="5">California</option>
</select>
<input type="submit" name="submit" value="Submit" /></form>
Location: <select name="location">
<option value="0">Kansas</option>
<option value="1">Alaska</option>
<option value="2">Alabama</option>
<option value="3">Kentucky</option>
<option value="4">New Jersey</option>
<option value="5">California</option>
</select>
<input type="submit" name="submit" value="Submit" /></form>
- <form action="submitted.php" method="post">
- Location: <select name="location">
- <option value="0">Kansas</option>
- <option value="1">Alaska</option>
- <option value="2">Alabama</option>
- <option value="3">Kentucky</option>
- <option value="4">New Jersey</option>
- <option value="5">California</option>
- </select>
- <input type="submit" name="submit" value="Submit" /></form>
submitted.php
PHP Código: [ Select ]
function strip_htmltags($array)
{
$return = array();
foreach($array as $key => $value)
{
$return[$key] = htmlspecialchars(trim($value));
}
return $return;
}
$_POST = strip_htmltags($_POST);
$locations = array(
'0' => <!-- e -->'x@kansas.com<!-- e -->',
'1' => <!-- e -->'x@alaska.com<!-- e -->',
'2' => <!-- e -->'x@alabama.com<!-- e -->',
'3' => <!-- e -->'x@kentucky.com<!-- e -->',
'4' => <!-- e -->'x@new.jersy.com<!-- e -->',
'5' => <!-- e -->'x@california.com<!-- e -->');
$location = $_POST['location'];
$email = $locations[$location];
echo $email;
{
$return = array();
foreach($array as $key => $value)
{
$return[$key] = htmlspecialchars(trim($value));
}
return $return;
}
$_POST = strip_htmltags($_POST);
$locations = array(
'0' => <!-- e -->'x@kansas.com<!-- e -->',
'1' => <!-- e -->'x@alaska.com<!-- e -->',
'2' => <!-- e -->'x@alabama.com<!-- e -->',
'3' => <!-- e -->'x@kentucky.com<!-- e -->',
'4' => <!-- e -->'x@new.jersy.com<!-- e -->',
'5' => <!-- e -->'x@california.com<!-- e -->');
$location = $_POST['location'];
$email = $locations[$location];
echo $email;
- function strip_htmltags($array)
- {
- $return = array();
- foreach($array as $key => $value)
- {
- $return[$key] = htmlspecialchars(trim($value));
- }
- return $return;
- }
- $_POST = strip_htmltags($_POST);
- $locations = array(
- '0' => <!-- e -->'x@kansas.com<!-- e -->',
- '1' => <!-- e -->'x@alaska.com<!-- e -->',
- '2' => <!-- e -->'x@alabama.com<!-- e -->',
- '3' => <!-- e -->'x@kentucky.com<!-- e -->',
- '4' => <!-- e -->'x@new.jersy.com<!-- e -->',
- '5' => <!-- e -->'x@california.com<!-- e -->');
- $location = $_POST['location'];
- $email = $locations[$location];
- echo $email;
Sólo tiene que añadir campos a este y su validación...Ya extracción y el recorte de todos los valores presentados aquí, así que debe ser aceptable.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
Página 1 de 1
Para responder a este tema que necesita para ingresar o registrarse. Es gratis.
Publicar Información
- Total de mensajes en este tema: 5 mensajes
- Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 135 invitados
- No puede abrir nuevos temas en este Foro
- No puede responder a temas en este Foro
- No puede editar sus mensajes en este Foro
- No puede borrar sus mensajes en este Foro
- No puede enviar adjuntos en este Foro
