Foros del Web » Creando para Internet » Flash y Actionscript »

Formulario de contacto

Estas en el tema de Formulario de contacto en el foro de Flash y Actionscript en Foros del Web. Hola, no se gran cosa de flash y tengo que cambiar un sitio web en flash de un hosting windows a un hosting linux, por ...
  #1 (permalink)  
Antiguo 28/03/2011, 02:46
Avatar de PosProdukcion  
Fecha de Ingreso: noviembre-2004
Ubicación: Manzanares el Real (Madrid)
Mensajes: 726
Antigüedad: 19 años, 4 meses
Puntos: 9
Formulario de contacto

Hola, no se gran cosa de flash y tengo que cambiar un sitio web en flash de un hosting windows a un hosting linux, por tanto, el formulario de contacto debo hacer que aounte a un script php en lugar de asp, he editado la accion de la capa/frame en cuestión para cambiar la url de POST pero obtengo siempre resultado erróneo, el script contacto.php solo hace echo('Result=Success&'), es decir, no debería dar ningún error. Este es el script:

¿Me podéis echar una mano?
Gracias

(por cierto, creo que el FLA original estaba en otra versión de flash más antigua, no se si esto puede influir)

Código actionscript:
Ver original
  1. //Declare variables
  2. //var SendURL:String = "http://www.miweb.es/contacto.asp";
  3. var SendURL:String = "http://www.miweb.es/contacto.php";
  4. var Result:String;
  5.  
  6. //Input variables
  7. var T_Firstname:TextField = Form_mc.Firstname_txt;
  8. var T_Lastname:TextField = Form_mc.Lastname_txt;
  9. var T_Email:TextField = Form_mc.Email_txt;
  10. var T_Company:TextField = Form_mc.Company_txt;
  11. var T_Subject:TextField = Form_mc.Subject_txt;
  12. var T_Message:TextField = Form_mc.Message_txt;
  13. var T_Telefono:TextField = Form_mc.Telefono_txt;
  14. var B_Send:Button = Form_mc.Send_btn;
  15.  
  16. //Validator variables
  17. var V_FirstnameValidator:TextField = Form_mc.FirstnameValidator;
  18. var V_LastnameValidator:TextField = Form_mc.LastnameValidator;
  19. var V_EmailValidator:TextField = Form_mc.EmailValidator;
  20. var V_CompanyValidator:TextField = Form_mc.CompanyValidator;
  21. var V_SubjectValidator:TextField = Form_mc.SubjectValidator;
  22. var V_MessageValidator:TextField = Form_mc.MessageValidator;
  23. var V_TelefonoValidator:TextField = Form_mc.TelefonoValidator;
  24. var FormHasErrors:Boolean = false;
  25.  
  26. //Hide validators first
  27. V_FirstnameValidator._visible = false;
  28. V_LastnameValidator._visible = false;
  29. V_LastnameValidator._visible = false;
  30. V_EmailValidator._visible = false;
  31. V_CompanyValidator._visible = false;
  32. V_SubjectValidator._visible = false;
  33. V_MessageValidator._visible = false;
  34. V_TelefonoValidator._visible = false;
  35.  
  36.  
  37. //Declare Required Fields
  38. var IsFirstnameRequired:Boolean = true;
  39. var IsLastnameRequired:Boolean = true;
  40. var IsEmailRequired:Boolean = true;
  41. var IsCompanyRequired:Boolean = true;
  42. var IsSubjectRequired:Boolean = true;
  43. var IsMessageRequired:Boolean = false;
  44. var IsTelefonoRequired:Boolean = true;
  45.  
  46. //Some settings for our form fields...
  47. //Set max lengths
  48. T_Firstname.maxChars = 25;
  49. T_Lastname.maxChars = 25;
  50. T_Email.maxChars = 30;
  51. T_Company.maxChars = 25;
  52. T_Subject.maxChars = 50;
  53. T_Message.maxChars = 500;
  54. T_Telefono.maxChars = 500;
  55.  
  56. //Set tabindexes (Tab order)
  57. T_Firstname.tabIndex = 0;
  58. T_Lastname.tabIndex = 1;
  59. T_Email.tabIndex = 2;
  60. T_Company.tabIndex = 3;
  61. T_Telefono.tabIndex = 4;
  62. T_Message.tabIndex = 5;
  63.  
  64.  
  65. B_Send.onRelease = function() {
  66.     ControlForm();
  67. };
  68.  
  69.  
  70. //We are ready to control form fields...
  71. function ControlForm() {
  72.    
  73. //Reset validators to check them again
  74. FormHasErrors = false;
  75. V_FirstnameValidator._visible = false;
  76. V_LastnameValidator._visible = false;
  77. V_EmailValidator._visible = false;
  78. V_CompanyValidator._visible = false;
  79. V_SubjectValidator._visible = false;
  80. V_MessageValidator._visible = false;
  81. V_TelefonoValidator._visible = false;
  82.    
  83.     //Check if the fields are required (from options)
  84.     if (IsFirstnameRequired) {
  85.         if (T_Firstname.text.length<3) {
  86.             //If firstname length is smaller than 3 then we have some problems
  87.             FormHasErrors = true;
  88.             V_FirstnameValidator._visible = true;
  89.         }
  90.     }
  91.     if (IsLastnameRequired) {
  92.         if (T_Lastname.text.length<3) {
  93.             FormHasErrors = true;
  94.             V_LastnameValidator._visible = true;
  95.         }
  96.     }
  97.     if (IsEmailRequired) {
  98.         //run email control function
  99.         if (!checkEmail(T_Email.text)) {
  100.             FormHasErrors = true;
  101.             V_EmailValidator._visible = true;
  102.         }
  103.     }
  104.     if (IsCompanyRequired) {
  105.         if (T_Company.text.length<3) {
  106.             FormHasErrors = true;
  107.             V_CompanyValidator._visible = true;
  108.         }
  109.     }
  110.     if (IsSubjectRequired) {
  111.         if (T_Subject.text.length<3) {
  112.             FormHasErrors = true;
  113.             V_SubjectValidator._visible = true;
  114.         }
  115.     }
  116.     if (IsMessageRequired) {
  117.         if (T_Subject.text.length<3) {
  118.             FormHasErrors = true;
  119.             V_MessageValidator._visible = true;
  120.         }
  121.     }
  122.    
  123.     if (IsTelefonoRequired) {
  124.         if (T_Telefono.text.length<3) {
  125.             FormHasErrors = true;
  126.             V_TelefonoValidator._visible = true;
  127.         }
  128.     }
  129.     //If our form has no errors we will send variables to our server-side page and go to next frame to show the result.
  130.     //We will use SendAndLoad to send the variables and get a result.
  131.  
  132.     if (FormHasErrors == false) {
  133.         //We will define 2 SendAndLoad objects: One for sending and the other one is for getting result
  134.         var Send_lv:LoadVars = new LoadVars();
  135.         var Load_lv:LoadVars = new LoadVars();
  136.  
  137.         //Define sending variables
  138.         Send_lv.Firstname = T_Firstname.text;
  139.         Send_lv.Lastname = T_Lastname.text;
  140.         Send_lv.Email = T_Email.text;
  141.         Send_lv.Company = T_Company.text;
  142.         Send_lv.Subject = T_Subject.text;
  143.         Send_lv.Message = T_Message.text;
  144.         Send_lv.Telefono = T_Telefono.text;
  145.        
  146.        
  147.         //Submit variables
  148.         Send_lv.sendAndLoad(SendURL,Load_lv,"POST");
  149.  
  150.         //Get result
  151.         Load_lv.onLoad = function(success:Boolean) {
  152.             if (success) {
  153.                 //Successfully sent and loaded  but this not means that we sent the mail...
  154.                 Result = Load_lv.Result;
  155.                 trace(Result);
  156.                 if (Result == "Success") {
  157.                     Form_mc.gotoAndStop(2);
  158.                 } else {
  159.                     Form_mc.gotoAndStop(3);
  160.                 }
  161.             } else {
  162.                 Form_mc.gotoAndStop(3);
  163.             }
  164.         };
  165.  
  166.     }
  167. }
  168.  
  169.  
  170.  
  171.  
  172. function checkEmail(inputEmail:String):Boolean {
  173.     //check for spaces
  174.     if (inputEmail.indexOf(" ")>0) {
  175.         return false;
  176.     }
  177.     //bust the email apart into what comes before the @ and what comes after              
  178.     var emailArray:Array = inputEmail.split("@");
  179.     //make sure there's exactly one @ symbol also make sure there's at least one character before and after the @
  180.     if (emailArray.length != 2 || emailArray[0].length == 0 || emailArray[1].length == 0) {
  181.         return false;
  182.     }
  183.     //bust apart the stuff after the @ apart on any . characters              
  184.     var postArray:Array = emailArray[1].split(".");
  185.     //make sure there's at least one . after the @
  186.     if (postArray.length<2) {
  187.         return false;
  188.     }
  189.     //make sure there's at least 1 character in in each segment before, between and after each .              
  190.     for (var i:Number = 0; i<postArray.length; i++) {
  191.         if (postArray[i].length<1) {
  192.             return false;
  193.         }
  194.     }
  195.     //get what is left after the last .
  196.     var suffix = postArray[postArray.length-1];
  197.     //make sure that the segment at the end is either 2 or 3 characters
  198.     if (suffix.length<2 || suffix.length>3) {
  199.         return false;
  200.     }
  201.     //it passed all tests, it's a valid email              
  202.     return true;
  203. }
  #2 (permalink)  
Antiguo 28/03/2011, 11:38
Avatar de Bandit
Moderador
 
Fecha de Ingreso: julio-2003
Ubicación: Lima - Perú
Mensajes: 16.726
Antigüedad: 20 años, 9 meses
Puntos: 406
Respuesta: Formulario de contacto

Hola PosProdukcion:
Aquí tienes una serie de links sobre formularios: http://www.google.com/search?client=...3768a36761ca95

Espero haberte sido de ayuda.
__________________
Bandit.
Si no sabes estudia y si sabes enseña.
http://www.banditwebdesign.com/

Etiquetas: contacto, formulario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:35.