Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/02/2009, 21:04
BAT
 
Fecha de Ingreso: enero-2008
Mensajes: 258
Antigüedad: 16 años, 2 meses
Puntos: 0
Ayuda con formulario

hola que tal, espero me puedan ayudar, tengo un formulario con 8 campos todos son para introducir texto pero no se que estoy haciendo mal este es mi codogo

stop();
System.useCodepage = true;
import mx.controls.*;
nombre_txt.tabIndex = 1;
apaterno_txt.tabIndex = 2;
amaterno_txt.tabIndex = 3;
carrera_txt.tabIndex = 4;
aegreso_txt.tabIndex = 5;
empresa_txt.tabIndex = 6;
correo_txt.tabIndex = 7;
tel_txt.tabIndex = 8;
reset_btn.tabIndex = 9;
enviar_btn.tabIndex = 10;

focusManager.defaultPushButton = enviar_btn;
Selection.setFocus(nombre_txt);

var escuchadorLimpiar:Object = new Object();
escuchadorLimpiar.click = function(evt:Object) {
nombre_txt.text = "";
apaterno_txt.text = "";
amaterno_txt.text = "";
carrera_txt.text = "";
aegreso_txt.text = "";
empresa_txt.text = "";
mail_txt.text = "";
tel_txt.text = "";
}
reset_btn.addEventListener("click", escuchadorLimpiar);


var escuchadorEnvia:Object = new Object();
escuchadorEnvia.click = function(evt:Object)
{
if (nombre_txt.text.length == 0) {
Alert.show("Introduzca su nombre", "Error", Alert.OK);
Selection.setFocus(nombre_txt);
return false;
}
if (apaterno_txt.text.length == 0) {
Alert.show("Introduzca su apellido Paterno", "Error", Alert.OK);
Selection.setFocus(apellidos_txt);
return false;
}

if (amaterno_txt.text.length == 0) {
Alert.show("Introduzca su apellido Materno", "Error", Alert.OK);
Selection.setFocus(apellidos_txt);
return false;
}

if (carrera_txt.text.length == 0) {
Alert.show("Introduzca su Carrera", "Error", Alert.OK);
Selection.setFocus(apellidos_txt);
return false;
}

if (aegreso_txt.text.length == 0) {
Alert.show("Introduzca el año de Egreso", "Error", Alert.OK);
Selection.setFocus(apellidos_txt);
return false;

}
if (empresa_txt.text.length == 0) {
Alert.show("Introduzca la empresa en que labora", "Error", Alert.OK);
Selection.setFocus(apellidos_txt);
return false;
}

if (tel_txt.text.length == 0) {
Alert.show("Introduzca su Telefono", "Error", Alert.OK);
Selection.setFocus(apellidos_txt);
return false;
}

function esMail(mail:String) {

if (mail.indexOf("@") > 0 && mail.indexOf("@") == mail.lastIndexOf("@")) {
if (mail.lastIndexOf(".") > mail.indexOf("@") + 1 && mail.lastIndexOf(".") < mail.length - 2) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
if (!esMail(mail_txt.text)) {
Alert.show("Introduzca un correo electrónico válido", "Error", Alert.OK);
Selection.setFocus(mail_txt);
return false;
}
var envio:LoadVars = new LoadVars();
envio.nombre = nombre_txt.text;
envio.apaterno = apaterno_txt.text;
envio.amaterno = amaterno_txt.text;
envio.carrera = carrera_txt.text;
envio.aegreso = aegreso_txt.text;
envio.email = mail_txt.text;
envio.telefono = tel_txt.text;

envio.onLoad = function(exito:Boolean) {
if (exito) {
nombre_txt.text = "";
apaterno_txt.text = "";
amaterno_txt.text = "";
carrera_txt.text = "";
aegreso_txt.text = "";
empresa_txt.text = "";
mail_txt.text = "";
tel_txt.text = "";

}
else {
Alert.show("Ha habido un error en el envío", "Error");
}
}

envio.sendAndLoad("enviar_mail.php", envio, "POST");
Selection.setFocus(nombre_txt);
}
enviar_btn.addEventListener("click", escuchadorEnvia);

y el codigo php es este:

<?php

header("Cache-Control: no-cache, must-revalidate");

$mensaje = $_POST['nombre'] . " " . $_POST['apaterno'] . " ";
$mensaje = $_POST['amaterno'] . " " . $_POST['carrera'] . " ";
$mensaje = $_POST['aegreso'] . " " . $_POST['empresa'] . " ";

$mensaje .= "(" . $_POST['email'] . ")\r\n\n";
$mensaje = $_POST['tel'] . " " .


$cabeceras = "From: [email protected]" . "\r\n" . "Reply-To: [email protected]" . "\r\n";

mail('[email protected]', 'Formulario', $mensaje, $cabeceras);

echo ("&exito=true");

?>

el codigo lo fui sacando de diferentes post de aqui "foros del web" y de un curso en linea "aulaclick" espero me puedan ayudar