PDA

View Full Version : sendAndLoad


macs
07-07-2003, 04:37 PM
I'm trying to send vars to a Perl script and load a response (via LoadVars.sendAndLoad). The send var's are wel received and parsed, but i don't a response back.....

Can sombody explain me?

Macs

as::_____________________________________________

zendVars = new LoadVars(); // frame 1
laadVars = new LoadVars();
laadVars.geladen="nee";

--

// send button
on (release) {
zendVars.Type = _root.Type;
zendVars.id = _root.id;
zendVars.xml_tot = _root.xml_tot;
zendVars.sendAndLoad("../cgi-bin/test2.pl", laadVars, "POST");
gotoAndPlay(3);
}

--

// frame 3
if (laadVars.geladen == "ja"){
gotoAndStop(5);
}
________________________________________________


perl code::________________________________________

#!/usr/local/bin/perl
$mail_prog = '/usr/lib/sendmail' ;

##################################
# parse data #
##################################

&GetFormInput;

##################################
# redefining vars #
##################################

$Type = $field{'Type'} ;
$id = $field{'id'} ;
$xml_tot = $field{'xml_tot'} ;

##################################
# sending mail #
##################################

$recip = "test\@domain.nl" ;

open (MAIL, "|$mail_prog -t");
print MAIL "To: $recip\n";
print MAIL "Reply-to: mark\@domain.nl \n";
print MAIL "From: mark\@domain.nl \n";
print MAIL "Subject: TEST.\n";
print MAIL "\n\n";
print MAIL "-------------------------------------------------\n" ;
print MAIL "::Type:: ".$Type."\n" ;
print MAIL "::ID :: ".$id."\n" ;
print MAIL "::XML :: ".$xml_tot."\n" ;
print MAIL "-------------------------------------------------\n" ;
print MAIL "\n\n";
close (MAIL);

###################################
# send back when loaded #
###################################

print "geladen=ja";

###################################
# data parser #
###################################

sub GetFormInput {

(*fval) = @_ if @_ ;

local ($buf);
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});
}
else {
$buf=$ENV{'QUERY_STRING'};
}
if ($buf eq "") {
return 0 ;
}
else {
@fval=split(/&/,$buf);
foreach $i (0 .. $#fval){
($name,$val)=split (/=/,$fval[$i],2);
$val=~tr/+/ /;
$val=~ s/%(..)/pack("c",hex($1))/ge;
$name=~tr/+/ /;
$name=~ s/%(..)/pack("c",hex($1))/ge;

if (!defined($field{$name})) {
$field{$name}=$val;
}
else {
$field{$name} .= ",$val";

#if you want multi-selects to goto into an array change to:
#$field{$name} .= "\0$val";
}


}
}
return 1;
}

###################################
# The End #
###################################

tg
07-07-2003, 04:51 PM
try a couple of things:

1. change:
print "geladen=ja";
to:
print "geladen=ja&";

2. put in:

laadVars.onLoad=function(done){
if(done){
trace(this);
if (this.geladen=='ja'){
gotoAndStop(5);
}
}
};

and comment out your code in frame 3

macs
07-08-2003, 10:04 AM
It works!

thnx Tg, you the man...



__________________________________________________ ____
The day you stop learning is the day you start getting old.
MS

KingCHAD
07-08-2003, 02:29 PM
a similar problem mine is with php

http://www.bullit.biz/home.htm

click on people and then guestbook