A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: A Simple CGI Question ???

  1. #1
    Member
    Join Date
    Apr 2000
    Posts
    36

    Red face


    A quick question regarding the CGI Mail Form Tutorial on Flashkit.com, I am having problems using the load variables statement, however when I use the Get URL statement everything works!

    Load Variables ("http://www.quasarweb.com/cgi-shl/formmail2.pl", 1, vars=POST)

    Does not work

    Get URL ("http://www.quasarweb.com/cgi-shl/formmail2.pl", window="_blank", vars=POST)

    Does work

    I do not want users to open up a separate window everytime they submit the form, however I cannot get the Load Variables Statement to work, any idea's why I am having trouble?

    I am using the code in the Flashkit example, it SHOULD work and does if I use regular HTML or the GET URL statement.

    Help!

  2. #2
    Last Ju-Jitsu Warrior
    Join Date
    Aug 2000
    Posts
    655
    Ok, use the Load Variables in this way:

    Load Variables ("http://www.quasarweb.com/cgi-shl/formmail2.pl", "", vars=POST)

    This should work. What I did is I selected it on Target and not a level, and I didn't write anything in the box. That's how I use cgi in Fash - so it must work.

    For more help, just ask...

  3. #3
    Member
    Join Date
    Apr 2000
    Posts
    36

    No Joy

    No Joy, tried the alteration you have suggested and I cannot get the form to work. Even with the GET URL variable in use the script seems to be unreliable.

    Is it possible that the Flash 4 Program I am using could be corrupt? The information is defiantely being sent, when testing the movie offline it 'sends' the information. I can only guess that the problem lies between Formmail receiving the variables and then sending the e-mail.

  4. #4
    Last Ju-Jitsu Warrior
    Join Date
    Aug 2000
    Posts
    655
    What you should do, is see if the CGI prints something back when the Email is done or anyplace else. Why? Because if the script will print back, and it can't print to flash, it'll ruin the whole thing!

    If you'll send me the script (no .fla's) i'll see what can be causing the problem, and try it myself...

    Waiting for your replay...

  5. #5
    Last Ju-Jitsu Warrior
    Join Date
    Aug 2000
    Posts
    655
    Look at the file I sent in you to your Email. Try it... If it still doesn't work, tell me... I'll figure it out.

  6. #6
    Member
    Join Date
    Apr 2000
    Posts
    36

    Unhappy .pl file sent

    I've sent you the .pl file. It is working as I said with regular HTML and with the GET URL action.

    For whatever reason it is just not working with LOAD VARIABLES. I can only guess that either the particular CGI form I am using is not interperating the variables correctly or cannot process them without moving to a new browser window. I don't think that the .fla file has any problems since as stated it works fine with GET URL, I also know that the .exe that sends the e-mails works since it does this with HTML.

    SO it must be the .PL file ... if you can see any reason why the script will not work I would greatly appreciate your help.

    Thanks again

  7. #7
    Last Ju-Jitsu Warrior
    Join Date
    Aug 2000
    Posts
    655
    I sent you the .pl file, try it!

  8. #8
    Member
    Join Date
    Apr 2000
    Posts
    36

    Still no Joy

    Still not having any luck, I could send you a .fla to have a look at if you haven't started pulling your hair out (like me).

  9. #9
    Last Ju-Jitsu Warrior
    Join Date
    Aug 2000
    Posts
    655
    Let's do it like this. Send me the .pl to email:
    shin@mycell.org

    And i'll make you a script that'll send the email and return variables to Flash.

    But, you need to give me the name of all variables sent to the script.

  10. #10
    Member
    Join Date
    Apr 2000
    Posts
    36

    URL

    You can see the live swf site at http://www.caterantrail.co.uk .. that should give you some idea of what I am looking to send. I don't really need anything back from the CGI file I only need a script that will send all the variables via e-mail.

    http://www.caterantrail.co.uk is the URL.

  11. #11
    Last Ju-Jitsu Warrior
    Join Date
    Aug 2000
    Posts
    655
    Then just use this simple simple code:

    Code:
    #!/usr/bin/perl
    # Get's the variables
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    @pairs = split(/&/, $buffer);
    foreach $pair (@pairs) {
            local($name, $value) = split(/=/, $pair);
            $name =~ tr/+/ /;
            $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
            $value =~ tr/+/ /;
            $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
            $value =~ s/<!--(.|\n)*-->//g;
                if ($Form{$name} && $value) {
                    $Form{$name} = "$Form{$name}, $value";
                }
                elsif ($value) {
                    push(@Field_Order,$name);
                    $Form{$name} = $value;
                }
        }
    open (MAIL,">your mail path") || die "CANT OPEN";
    	print MAIL "To: $Form{'mail_to'}\n";
    	print MAIL "From: $Form{'mail_from'}\n";
    	print MAIL "Reply-to: $Form{'mail_from'}\n";
    	print MAIL "Subject: $Form{'mail_subject'}\n\n";
    	print MAIL "Someone sent you Email from your site, here is the message:\n\n";
    	print MAIL "$Form{'mail_body'}\n";
    close (MAIL);
    You need to send these variables to the CGI:
    mail_to
    mail_from
    mail_subject
    mail_body

    I'll let you guess what each variable is.
    Don't forget to change the "your mail path" to the correct path.

    Hope it'll work...

  12. #12
    Member
    Join Date
    Apr 2000
    Posts
    36

    Thanks

    Thank you very much for your help Shin, over and above the call of duty.

    I'll try to fiddle about with the formmail.pl script for a little while longer due to its sort facility. If I can't get that to work then I will definately use your code.

    Thanks Again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center