4 Replies Latest reply on Feb 14, 2007 9:57 AM by scholzr

    Text Input in loadVar

    scholzr Level 1
      OK, so I know that this is probably a VERY simple question, but I am new to Flash, so can somebody please help? I am trying to post the contents of several text inputs to a CGI script when the user clicks a submit button using the following script: (I have removed the address to the actual CGI script)

      on (click) {
      var my_lv:LoadVars = new LoadVars();
      my_lv.name = name.text;
      my_lv.email = email.text;
      my_lv.phone = phone.text;
      my_lv.regarding = regarding.text;
      my_lv.message = message.text;
      my_lv.send("[cgi-url]", "_blank", "POST");
      }


      It was my understanding that this should post the results of each of the inputs to the CGI page using the name specified in the script (name, email, phone, etc) as the variable name. Is this true? If so, any ideas why my CGI script does not recognize the variables?

      Thanks
        • 1. Re: Text Input in loadVar
          satrop Level 1
          Any reasion for using CGI script? I can help if you want to do it with php script. I had the same(ish) problem. But using the php script worked a treat!
          • 2. Re: Text Input in loadVar
            scholzr Level 1
            I was using CGI because it was what I had found in a tutorial. I would really prefer to use PHP as that is what my background is it.
            • 3. Re: Text Input in loadVar
              satrop Level 1
              Ok! No problem!! Hear's what the php script is gonna look like!>

              <?php
              $sendTo = "youraddress@thisplace.com";
              $subject = "The Title Of the Email";
              $headers = "From: " . $_POST["name"];
              $headers .= "<" . $_POST["email"] . ">\r\n";
              $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
              $headers .= "Return-Path: " . $_POST["email"];
              $message .= $_POST["change to the name of you text field var"] . "\r\n\n";
              $message .= $_POST["change to the name of you text field var"] . "\r\n\n";
              $message .= $_POST["change to the name of you text field var"] . "\r\n\n";
              $message .= $_POST["change to the name of you text field var"] . "\r\n\n";
              $message .= $_POST["change to the name of you text field var"] . "\r\n\n";

              mail($sendTo, $subject, $message, $headers);

              Ok, with is bit of code put it in the root folder in your site. Titled "email.php" That was the easy part?! Now for the flash side>

              You have to make a movie clip name it "form" into which all the varibles (the text you want to be sent to an email address) must go. Attach this code to your send button>

              on (release) {
              form.loadVariables("email.php", "POST");
              }

              And that should do it? If you have any problems getting it to work you can send me your .fla file so I can have a look at it. I'll send you my email address in a private message. Hope this helped and have a good day!
              • 4. Re: Text Input in loadVar
                scholzr Level 1
                Thanks,

                I created the php file, and was able to send emails with it using a regular html file sending the same variables as my flash, but I was not able to get my form to submit. My form is already in it's own movie clip, so I changed the name in the button script to match, but it does not seem to do anything when I press the submit button. Any ideas?