Link to home
Start Free TrialLog in
Avatar of ziffgone
ziffgoneFlag for Canada

asked on

Create a Form in CGI

Is it possible to create a Form in CGI instead of HTML and have it post to another CGI script?

Regards...
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ziffgone

ASKER

You are right Tintin, poor terminology.

Can you add Hidden fields to this form?

Also, I do need to send to another CGI program. I am sending the info to a third party and their CGI program would decipher what I have sent. How could I do this?

The hope here is that any hidden field can be pulled from within the CGI script and not show up in the HTML source.

Avatar of Tintin
Tintin

You can use hidden fields just as you'd use them in a HTML file.  The Perl CGI module has HTML shortcuts, but you can write your own HTML code, eg:

print header;
print <<EOF;
<html>
...
<form action="http://www.example.com/cgi-bin/remote_script.cgi" method="post">
....
</form>
</html>
EOF

Note the form action sends the form query to the remote server.  Note, you'll need to check whether it uses GET or POST.
Yup. Not what I'm looking for. I was looking for a way to truly hide the Hidden feilds of a form.

There is a program that comes close, Master Secret Hidden Fields at http://willmaster.com/master/secrethiddenfields/

Seems like a pretty sloppy program though given that there's better ways of doing what it does, so I'm not sure it's the way I want to go. Something along this line though.

Thanks...
Well, if the remote CGI program uses the POST method, then you can just bundle everything up in a POST request and not worry about hidden fields.

What are you trying to hide anyway?
Trying to hide the return value in a PayPal button form for an Instant Downloadable product.

What would be the code to send this data via POST request? I have tried this before with no success.

Thanks Tintin...
Here's an example POST request

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$ua = LWP::UserAgent->new;  

my $req = POST 'http://www.perl.com/cgi-bin/BugGlimpse',
                [ search => 'www', errors => 0 ];  

print $ua->request($req)->as_string;
Is there a way to Send the info to the page specified instead of bringing the page content to your server?

Here is what I have right now:

CODE: ---------------------------------------------------
#!/usr/bin/perl -w

use CGI;

# delete next line before running when fixed
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$ua = LWP::UserAgent->new;  

$req = POST 'https://www.paypal.com/cgi-bin/webscr',
                [ cmd => '_xclick', business => 'myemail@mydomain.com', item_name => 'Test_Item', item_number => '001', amount => '0.01', return => 'http://www.google.com/', cancel_return => 'http://www.google.com', no_note => '1', currency_code => 'USD' ];  

print "Content-type: application/x-www-form-urlencoded";
print $ua->request($req)->as_string;
ENDCODE: -----------------------------------------------------
For an example of what it does:
http://webmastereseller.com/cgi-bin/post.cgi

You'll see the PayPal page come up, but because the page is requested to my server, all of the images don't show etc. If you click on the Login button, the page transfers to PayPal and everything is correct.

How can I send the info to PayPal instead of bringing the PayPal page to me? Would it be a different command than "request($req)"? Something along the line of "send($req)"?

Your thoughts...