develooper Front page | perl.libwww | Postings from July 2001

Re: Perl

From:
Phil Price
Date:
July 24, 2001 13:56
Subject:
Re: Perl
Message ID:
000201c113ba$17cfbe60$0100000a@scooby
Hi Syed,

Right

a) Your questions doesnt make sence, too breif, what exactly is the
problem!? Bar "it doesnt work"
b) I dont think its a good idea to post things lots of times, as if some one
didnt reply the first time they posting it losts of times is not going to
get them to reply (bar flames)
c) It /looks/ like a CGI question now a libwww-perl one, i think
cgi-list@jann.com is your best bet ;) (subscribe at http://cgi.jann.com
iirc)
d) I can spot bout at least 5 things your doing wrong, or i can guess you
havnt done, but this isnt the place for that..


Yours
--
Phil Price
e: me@philprice.net
w: www.philprice.net
w: www.spearfoot.com


----- Original Message -----
From: "Syed Shah" <shaha1s@mail.cmich.edu>
To: <libwww@perl.org>
Sent: Monday, July 23, 2001 12:31 AM
Subject: Perl


> I ran the following in Netscape. However, when I click submit it does not
> anywhere. The CGI program is in the same directory as this file. Please
> help. Thanks.
>
> <HTML>
> <HEAD>
> <title>A SURVEY FORM</TITLE>
> </HEAD>
> <BODY>
> <H2> A Survey Form</h2>
> <FORM ACTION="survey.cgi" METHOD="post">
> <P>Name: <INPUT TYPE="text" NAME="name" SIZE=30 MAXSIZE=50>
> </P>
> <P> <INPUT TYPE="checkbox" NAME="Purchaser" Value="yes">
> I am authorized to make purchased.
> </P>
> <P>
> IT Budget:<BR>
> <INPUT TYPE="radio" NAME="budget" VALUE="10000">Less Than $10,000<BR>
> <INPUT TYPE="radio" NAME="budget" VALUE="100000">From $10,000 to
$100,000<BR>
> <INPUT TYPE="radio" NAME="budget" VALUE="1000000">From $100,000 to
> $1,000,00<BR>
> </p>
> <p>
> Current Job Responsibility:
> <SELECT NAME="JOB" SIZE=1>
>          <OPTION VALUE="senior">Senior Management
>          <OPTION VALUE="management">Management
>          <OPTION VALUE="engineer">Engineer
>          <OPTION VALUE="conultant">Consultant
> </SELECT>
> </P>
> <p>
> Comment:<BR>
> <TEXTAREA NAME="comments" WRAP="virtual" cols=60 rows=10></TEXTAREA>
> </p>
>
> <p>
> Color:<BR>
> <SELECT NAME="color" SIZE=1>
>          <OPTION VALUE="red">Red
>          <OPTION VALUE="blue">Blue
>          <OPTION VALUE="yellow">Yellow
> </SELECT>
> </P>
>
> <p>
> Operating System:<br>
> <SELECT NAME="operating-system" SIZE=4 MULTIPLE>
>          <OPTION VALUE="macos">MAC
>          <OPTION VALUE="linux">Linux
>          <OPTION VALUE="freebsd">FreeBSD
>          <OPTION VALUE="windows">Windows
> </SELECT>
> </P>
> <P>
> <INPUT TYPE="submit">
> <INPUT TYPE="reset">
> </P>
> </FORM>
> </BODY>
> </HTML>
>
> The CGI file is:
>
> #!c:\perl\bin\perl.exe
> #/usr/local/bin/perl
>
> print "Content-type:text/html\n\n";
>
>
> 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;     # replace newlines with spaces
>
>          $value =~ s/\r//g;      # remove hard returns
>
>          $value =~ s/\cM//g;     # delete ^M's
>
>          $FORM{$name} = $value;
>
> }
>
>
> open(OUTF,">>survey.out") or dienice("Couldn't open survey.out for
>
> writing: $!");
>
>
> # This locks the file so no other CGI can write to it at the
>
> # same time...
>
> flock(OUTF,2);
> # Reset the file pointer to the end of the file, in case
>
> # someone wrote to it while we waited for the lock...
>
> seek(OUTF,0,2);
>
> print OUTF "$FORM{'name'}|$FORM{'email'}|";
>
> print OUTF "$FORM{'howreach'}|$FORM{'rating'}|";
>
> %boxes = (      "des" => "Website Design",
>
>                          "svr" => "Web Server Administration",
>
>                          "com" => "Electronic Commerce",
>
>                          "mkt" => "Web Marketing/Advertising",
>
>                          "edu" => "Web-Related Education" );
>
> foreach $key (keys %boxes) {
>
>          if ($FORM{$key} == 1) {
>                  print OUTF "$key,";
>
>          }
>
> }
>
>
> print OUTF "|$FORM{'comments'}\n";
>
> close(OUTF);
>
>
> print <<EndHTML;
>
> <html><head><title>Thank You</title></head>
>
> <body>
>
> <h2>Thank You!</h2>
>
> Thank you for your feedback.<p>
>
> <a href="index.html">Return to our home page</a><p>
>
> </body></html>
>
> EndHTML
>
>
> sub dienice {
>
>          my($msg) = @_;
>
>          print "<h2>Error</h2>\n";
>
>          print $msg;
>
>          exit;
>
> }
>
>




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About