Quote:
Originally posted by instruction:
However the examples given in those tutorials, assume that you know the "VALUE" of the variables. For instance say you assigned the variable name --> f_name to the "what is your first name:" field of a form. When the user types in whate there name is, I nor my program know what the value of f_name is: Well I do, but the examples all use literal strings, so You can not put something like:
f_name => '$form{\'required-f_name\'}'; 
That is not literal. So how would I get the literal string---> say they typed:
freddy. <---how do you get your program to come up with the literal string rather then haveing it assigned to a variable?
Any ideas? This probably made no since, and if it doesn't I am sorry.
|
k, let me answer your question with a question.
Doesn't your verification script know the key/value pairs for the data submitted by the form? For example
required-f_name = freddy
right?
Isn't "required-f_name" the name in the form for the field where they enter the first name, and the value entered would be something like "freddy"?
But you are saying, if I understand you correctly, that you don't know "freddy"? Then I don't understand how you are validating the data with the previous step? How can the validation script do it's thing if it only has $form{\'required-f_name\'} instead of "freddy" ?
This is the information you need to pass to cgiemail after you've validated the data?
So, it looks to me, from the lwpcookbook (linked from one of the references above) that once you've validated the data, your validation script could pass it on to cgiemail as follows:
(see
the section on POST in the lwpcookbook)
Code:
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
my $req = POST 'http://www.yourdomain.com/cgi-bin/cgiemail/template.txt',
[ required-f_name => 'freddy', required-l_name => 'smith' ];
print $ua->request($req)->as_string;
I'm not sure, but maybe this would work also (I would think so?):
Code:
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
my $req = POST 'http://www.yourdomain.com/cgi-bin/cgiemail/template.txt',
[ required-f_name => $form{\'required-f_name\'},
required-l_name => $form{\'required-l_name\'} ];
print $ua->request($req)->as_string;
I can't see why the above wouldn't work, in the case that you don't know the actual values from the form. However, I won't be testing it for you, as I don't program in Perl. (Mostly use Python at the moment.) Anyhow, I hope the above is right. I would suggest testing it out and seeing what happens. Or, maybe some of the Perl experts will come in here and double-check/verify the above. I'm really more comfortable discussing Python. (I already looked to see that Python can also do this, see
http://www.python.org/doc/current/li...e-urllib2.html . So, I have learned something useful for me, as well.

)
[edit: I know I have made syntax errors in the above with misplaced quote marks, or not escaping certain characters. I think the meaning is clear though? I'm loathe to try and do much correcting, since I'm not really sure of the correct syntax anyhow.]