3 Replies Latest reply on May 29, 2007 12:25 PM by urbanrevolution

    flash form to PHP/database

    urbanrevolution Level 1
      i'm going crazy and i hope someone can help me

      here is the script i'm trying to pass to the php page

      PHP Checkbox tutorial
      www.flashscript.biz, 2005
      stop ();
      // importing button and checkbox class
      var name_txt:mx.controls.TextInput;
      var email_txt:mx.controls.TextInput;
      var company_txt:mx.controls.TextInput;
      var newsletter:mx.controls.CheckBox;
      var submitBut:mx.controls.Button;
      var messageBox:TextField;
      // LoadVars objects
      var lv:LoadVars;
      lv = new LoadVars ();
      var lvAnswer:LoadVars;
      lvAnswer = new LoadVars ();
      // button label
      submitBut.label = "Submit";
      // we give "myCheckbox" a default value
      var myCheckbox:String;
      myCheckbox = "selected";
      // we create a listener for the checkbox to increase either number
      var checkListener:Object = new Object ();
      checkListener.click = function () {
      // here we let the user select
      if (newsletter.selected) {
      myCheckbox = "isSelected";
      } else {
      myCheckbox = "not selected";
      newsletter.addEventListener ("click", checkListener);
      // sending out the data
      submitBut.onRelease = function () {
      messageBox.text="Please wait.";
      lv.name_txt = name_txt;
      lv.email_txt = email_txt;
      lv.company_txt = company_txt;
      lv.myCheckbox = newsletter;
      lv.action = "send";
      lv.sendAndLoad ("includes/techinfo_signup.php", lvAnswer, "POST");
      // receiving the data from the php file
      lvAnswer.onLoad = function () {
      messageBox.text = this.result;

      the text field caomes back as undefined
      the php page is calling
      myCheckbox / newsletter

      here is the url so you can see what i'm talking about... http://www.lightningmedia.com/form_test.php

      any help would save me life.... thanks

        • 1. Re: flash form to PHP/database
          Greg Dove Level 4
          Try this type of approach... you need to get the text properties of the textInputs etc. and its probably better to use the click event on the button component, although perhaps the onRelease handler will work just as well.

          Note the comment for your checkbox value being sent. Depends on what your php script is expecting.

          (I haven't tested this,so if it doesn't work let me know)
          • 2. Re: flash form to PHP/database
            urbanrevolution Level 1
            thanks for getting back to me...
            i've tried it and it's still not working...

            still trying to find a solution...

            • 3. Re: flash form to PHP/database
              urbanrevolution Level 1
              ok so i;ve gon back to the down a dirty way of doing this...
              http://www.lightningmedia.com/form_test.php (technical info tab)

              each text field has a Var: Name, email, and company
              i've used the CheckBox component

              i;ve placed the fallowing code on the submit button

              on (release) {
              if (!email.length || email.indexOf("@") == -1 || email.indexOf(".") == -1) {
              EmailStatus = "Please enter a valid E-mail address";
              } else {
              loadVariablesNum("includes/techinfo_signup.php", 0, "POST");

              easy enough right?

              everything works fine but the CheckBox......
              i'm trying to send a 1 or 0 to the database.

              i've given the component a
              fieldname: newsletter (the same as the field in the database)
              data type: Boolean
              required: true
              Read only: false
              kind: data
              default value:1
              path: includes/techinfo_signup.php
              storage type: simple

              so what am i missing? i'm at a loss...

              thanks again