Posting Data to a CGI Script

I have a login script called login.cgi. Currently I use a HTML form to login. I created a Flash form to use as the login in but when I click on the submit button nothing happens.

here is the code

on (release) {
loadVariables (“”, _root, “POST”);
gotoAndStop (2);

does the script need to be written for Flash? The HTML form uses “post” to send the variables.

what’s supposed to happen?

once a user enters the user name and password the script will verify the user name then display a HTMl page after login in.

use getURL instead and _blank as a target, that will make the results come back in a new window.

I tried setting the taget to _blank and using the GET but nothing happened.

here is the action:
on (release) {
loadVariables (“”, _blank, “GET”);

The original html form uses the POST method. I tried using POSt and the traget _blank but I got the same result.

here is the url to the form.

I really do appreciate your help!

try putting _blank in quotes. POST should work fine, it’s safer than GET.

I still can’t get it to work. Will you look at the .fla file? If so you can download it from

the html page is

I must be missing something obvious. I looked in the Flash 5 Bible and it appears that I am writing the action correctly.

use getURL, like so:

   getURL("", "_blank", "POST");

now it works!!

that script does bring up the for built into the script but I was trying to use the flash form to login.

I guess it won’t work.

thanks for you help

ok, i had a closer look at the page that the cgi produces.

the script is looking for a variable “action”. when you call it from flash without setting it, the cgi sees that the variable is null, and gives you the login prompt instead of processing the info.

you’ll have to set the “action” variable to “login”.

you can set that anywhere, but perhaps easiest on the submit button:

on (release) {
   getURL("", "_blank", "POST");


I think I am a lot closer now. Here is what’s going on. Once you click on the “LOGIN” button, the script reuturns 2 errors.

1 Invalid character in username.
2 No such username / password combination

The variables are not being posted. The script thinks the variables are blank. I read inside the cgi file and “whitespace” will create the “invalid character” error. I can re-create this same error on my original form by not enter a username / password. Form some reason the loadVariables.

here is the original form

the flash form

I know this has taken your tim and I sure you are a busy person but I really do appreciate your help.

Sincerely, Jay

you could try urlencoding the data before sending it. that’s

my_pass = escape(my_passwd);
my_user = escape(my_user);

otherwise i’d have to have a look at the cgi.


doesn’t there need to be an action to load the varialbles? How does it post them otherwise? I tried the urlencoding like this.

my_pass = escape(my_pass);
my_user = escape(my_user);
&nbsp &nbsp &nbsp &nbsp getURL("<a href=“",">”,</a> “_self”, “POST”);


this produced the same result.

whatever variables exist in the movie that the action is initiated form are passed. if you want to be sure that variables are being passed, call this script (this is perl), it will simply print everything that it receives:


use CGI qw(:standard);


print "Content-type: text/html


foreach $key (sort keys %ENV) {
_ _ _ _ print "$key = $ENV{$key}

foreach $key (sort keys %fields) {
_ _ _ _ print "$key = $fields{$key}


sub get_data
  foreach $item(@pairs)
    $content=~tr/+/ /;


it’s a great troubleshooting script

I pasted the script into a file called “”.

I set the action on the submit button as follows.

getURL("<a href=“",">”,</a> “”, “POST”);

does the file need to be CHMOD?



did a little experimenting … here’s a few things.

uncheck html on your text options, it’s sending the html code as well.

you’ll want to be sure to unencode the keys if you want to use underscores. with the script i posted above, the underscores are not being translated back to underscores, they remain “%5F”. this is * without* escaping the variables first. seems to do it automatically when it POSTS.

see the line that unencodes the $content? just do the same for $key like so:


i think that should clear up the problems. you might consider dumping the underscores altogether.


i got it to work!!

I got rid of the underscore and changed the html setting on the text input fields.

Thanks a LOT! I wouldn’t have ever got that to work without your help!

Have a good weekend.