Re: [MacPerl-WebCGI] Un-webifying HTML User Data Question

[email protected] (Bradley Creamer) Thu, 10 May 2001 14:09:21 -0700
Newsgroups perl.macperl.webcgi
Message-ID <[email protected]>
Greg!

Here's how I do it... if you know the input names from your from, which I am
guessing that you probably do...

use CGI qw(:standard);
use Fcntl;


$FromFirst = param("FromFirst");
$FromLast = param("FromLast");
$Email = param("Email");
$Phone = param("Phone");
$Amount = param("Amount");
$Design = param("Design");
$Account = param("Account");
$Expire = param("Expire");
$ToFirst = param("ToFirst");
$ToLast = param("ToLast");
$ToAddress = param("ToAddress");
$ToAddress2 = param("ToAddress2");
$ToCity = param("ToCity");
$ToState = param("ToState");
$ToZip = param("ToZip");
$ToStatement = param("ToStatement");


Then I just use my variables in the the rest of my script.

Hope this helps a little.



Bradley Creamer
Sonoma State Enterprises, Webmaster
[email protected]
(707) 664-4382



----------
>From: Gregory Smith <[email protected]>
>To: [email protected]
>Subject: [MacPerl-WebCGI] Un-webifying HTML User Data Question
>Date: Thu, May 10, 2001, 6:46 AM
>

> Hello,
>
> Sorry if this issue has been beaten into the ground before.  I looked
> through the webcgi archives and didn't see anything that I thought could
> help me here.
>
> I'm wondering if one of you kind folks could point me to how to "un-webify"
> data passed from an HTML form for use in a MacPerl CGI?  My Perl/CGI
> experience is with *nix CGI scripts.  When I attempt to run my "un-webify"
> code under MacPerl with a WebStar Server, MacPerl crashes.  The test code
> below and HTML form run fine on my *nix box.  I CAN get a simple "Hello
> World" CGI to run on the WebStar server so I know that at least the base
> install of MacPerl is functioning.
>
> I don't seem to be able to find specific information regarding this issue.
> I have MacPerl: Power And Ease and have read the short chapter on CGI
> scripts.
>
> I would be greatly appreciate if anyone could point out what I'm doing wrong
> or where to look for specific information.
>
> So far I have my "real" script running fine locally.  So I know the base
> code does what I want it to do. I just can't seem to get the user data
> passed to the CGI from the HTML form page.
>
> Here's a test script using my usual  *nix "un-webify" code which will crash
> or freeze MacPerl on my WebStar server:
> -=-=-=-=-=-=-=-=-=-=-
>
> #!perl -w
> use CGI;
> my($cgi) = new CGI;
>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
>    ($name, $value) = split(/=/, $pair);
>    $value =~ tr/+/ /;
>    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>    $value =~ s/<!--(.|\n)*-->//g;
>    $FORM{$name} = $value;
> }
>
> print $cgi->header();
> print "Hello $FORM{'real_name'}\n\n"; # Print user data
> print "$ENV{'CONTENT_LENGTH'}\n";     # Print string passed from HTML form
> 0;
>
> -=-=-=-=-=-=-=-=-=-=-
>
> At this point, I'm just trying to pass the data from the HTML form to the
> CGI and then simply printing out the data back to the browser.
>
> Thanks for your help!
> --
>
> Thanks,
> Greg Smith